Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 8, 2022 11:36 am GMT

React, Vue and Svelte: Comparing Checkbox Binding

Checkbox Binding in...

You should not fear checkbox binding in any of these frameworks. At least, one checkbox is easy to handle :)
But as we delve deeper into Form Binding, you'll see that Vue and Svelte offer something fluid.

Check it out

React

Live Example

const [checked, setChecked] = useState<boolean>(false);const handleCheckbox = () => setChecked(!checked);<section>  <h2>Checkbox</h2>  <input    type="checkbox"    id="checkbox"    checked={checked}    onChange={handleCheckbox}  />  <label for="checkbox">Checked: {checked.toString()}</label></section>

Vue

Live Example

const checked: Ref<boolean> = ref(false);<section>  <h2>Checkbox</h2>  <input type="checkbox" id="checkbox" v-model="checked" />  <label htmlFor="checkbox">Checked: {checked.toString()}</label></section>

Svelte

Live Example

let checked: boolean = false;<section>  <h2>Checkbox</h2>  <input type="checkbox" id="checkbox" bind:checked={checked} />  <label for="checkbox">Checked: {checked}</label></section>

Original Link: https://dev.to/ccreusat/react-vue-and-svelte-comparing-checkbox-binding-58fc

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To