1- import React , { useRef } from "react" ;
1+ import React , { useState } from "react" ;
22import ReactDOM from "react-dom/client" ;
3- import { IgrCheckboxChangeEventArgs , IgrComboModule , IgrCombo , IgrSwitchModule , IgrSwitch } from "igniteui-react" ;
3+ import { IgrCombo , IgrSwitch } from "igniteui-react" ;
44import "./index.css" ;
55import "igniteui-webcomponents/themes/light/bootstrap.css" ;
66import { Cities } from "./ComboData" ;
77
8- IgrComboModule . register ( ) ;
9- IgrSwitchModule . register ( ) ;
10-
118export default function ComboFeatures ( ) {
12- const comboRef = useRef < IgrCombo > ( null ) ;
13- const switchCaseSensitiveRef = useRef < IgrSwitch > ( null ) ;
14-
15- const disableFiltering = ( e : IgrCheckboxChangeEventArgs ) => {
16- comboRef . current . disableFiltering =
17- switchCaseSensitiveRef . current . disabled = e . detail . checked ;
18- } ;
19-
20- const showCaseSencitiveIcon = ( e : IgrCheckboxChangeEventArgs ) => {
21- comboRef . current . caseSensitiveIcon = e . detail . checked ;
22- } ;
23-
24- const enableGrouping = ( e : IgrCheckboxChangeEventArgs ) => {
25- comboRef . current . groupKey = e . detail . checked ? "country" : undefined ;
26- } ;
27-
28- const disableCombo = ( e : IgrCheckboxChangeEventArgs ) => {
29- comboRef . current . disabled = e . detail . checked ;
30- } ;
9+ const [ disableFiltering , setDisableFiltering ] = useState ( false ) ;
10+ const [ caseSensitiveIcon , setCaseSensitiveIcon ] = useState ( false ) ;
11+ const [ groupingEnabled , setGroupingEnabled ] = useState ( false ) ;
12+ const [ comboDisabled , setComboDisabled ] = useState ( false ) ;
3113
3214 return (
3315 < div className = "sample" >
@@ -38,26 +20,29 @@ export default function ComboFeatures() {
3820 placeholder = "Pick a city"
3921 placeholderSearch = "Search for a city"
4022 data = { Cities }
41- ref = { comboRef }
42- > </ IgrCombo >
23+ disableFiltering = { disableFiltering }
24+ caseSensitiveIcon = { caseSensitiveIcon }
25+ groupKey = { groupingEnabled ? "country" : undefined }
26+ disabled = { comboDisabled } >
27+ </ IgrCombo >
4328 < div className = "options" >
44- < IgrSwitch onChange = { disableFiltering } >
45- < span key = "filtering" > Disable Filtering</ span >
29+ < IgrSwitch checked = { disableFiltering } onChange = { e => setDisableFiltering ( e . detail . checked ) } >
30+ < span > Disable Filtering</ span >
4631 </ IgrSwitch >
47- < IgrSwitch onChange = { showCaseSencitiveIcon } ref = { switchCaseSensitiveRef } >
48- < span key = "caseSensitive" > Show Case-sensitive Icon</ span >
32+ < IgrSwitch checked = { caseSensitiveIcon } onChange = { e => setCaseSensitiveIcon ( e . detail . checked ) } >
33+ < span > Show Case-sensitive Icon</ span >
4934 </ IgrSwitch >
50- < IgrSwitch onChange = { enableGrouping } >
51- < span key = "grouping" > Enable Grouping</ span >
35+ < IgrSwitch checked = { groupingEnabled } onChange = { e => setGroupingEnabled ( e . detail . checked ) } >
36+ < span > Enable Grouping</ span >
5237 </ IgrSwitch >
53- < IgrSwitch onChange = { disableCombo } >
54- < span key = "disabled" > Disable Combo</ span >
38+ < IgrSwitch checked = { comboDisabled } onChange = { e => setComboDisabled ( e . detail . checked ) } >
39+ < span > Disable Combo</ span >
5540 </ IgrSwitch >
5641 </ div >
5742 </ div >
5843 ) ;
5944}
6045
61- // rendering above class to the React DOM
46+ // rendering above function to the React DOM
6247const root = ReactDOM . createRoot ( document . getElementById ( "root" ) ) ;
6348root . render ( < ComboFeatures /> ) ;
0 commit comments