Code
Props
Props
Data Type
Required
Event Response
Property
Data Type
onChange
Components Dependency
Live Demo
React
Last updated
Last updated
import React, {useState} from 'react';
import {Checkbox} from '@2600hz/sds-react-components';
const Example = ()=>{
const [checkboxList, setCheckboxList] = useState({
//In this case, instead capturing the value, for the example we only
//want to know if the component is checked or not
first: false,
second: false
});
const updateState = (e)=>{
setCheckboxList(prevState => ({
...prevState,
[e.id]: e.checked
}));
}
return(
<div className='container'>
<Checkbox
id='first'
value='element1'
label='Element 1'
onChange={updateState}
/>
<Checkbox
id='second'
value='element2'
label='Element 2'
onChange={updateState}
/>
</div>
)
}