반응형
Hello this is GOJIP programmer.
I just started write for share information about React js.
Usually, we use
</input type="checkbox" >
</input type="checkbox" >
checkbox like this, but sometimes we use this with making toggle.
When I foung this with google, I only found
<input type="checkbox" defualtvalue={true} >
this, they told me to use "defualtvlaue"
But didn't work really becuse input type is checkbox.
Here is how I made,
const [checked, setChecked] = React.useState(true);
<input type="checkbox" checked={checked} onClick={()=>setChecked(!checked) />
U have to use "checked" parameter.
If you want to put API value, then
<input type="checkbox" checked={API_VALUE} onClick={()=>setChecked(!API_VALUE) />
use like this.
Thank you
728x90
반응형