11
22import { ButtonComponent , CheckBoxComponent } from '@syncfusion/ej2-react-buttons' ;
33import { enableRipple } from '@syncfusion/ej2-base' ;
4+ import { ChangeEventArgs } from '@syncfusion/ej2-buttons' ;
45import * as React from 'react' ;
56import * as ReactDom from 'react-dom' ;
67import { useState } from 'react' ;
@@ -9,11 +10,12 @@ enableRipple(true);
910function App ( ) {
1011 const [ isChecked , setIsChecked ] = useState ( false ) ;
1112
12- const handleCheckboxChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
13- setIsChecked ( event . target . checked ) ;
13+ const handleCheckboxChange = ( event : ChangeEventArgs ) => {
14+ const checked = event . checked ?? false ;
15+ setIsChecked ( checked ) ;
1416
1517 // Add or remove the class on the body element based on the checkbox state
16- if ( event . target . checked ) {
18+ if ( checked ) {
1719 document . body . classList . add ( 'dark' ) ;
1820 document . body . classList . add ( 'e-dark-mode' ) ;
1921 } else {
@@ -24,7 +26,7 @@ function App() {
2426 return (
2527 < div >
2628 { /* checkbox - Used to represent checkbox. */ }
27- < CheckBoxComponent label = "Enable Darkmode" checked = { isChecked } onChange = { handleCheckboxChange } /> < br />
29+ < CheckBoxComponent label = "Enable Darkmode" checked = { isChecked } change = { handleCheckboxChange } /> < br />
2830 { /* Primary Button - Used to represent a primary action. */ }
2931 < ButtonComponent cssClass = 'e-primary' > Button</ ButtonComponent >
3032
0 commit comments