Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactJS and JSX - can I have uncontrolled checkbox?

In React I can have uncontrolled text inputs by using defaultValue property. However, there is no such property for checkboxes (there is only checked, which makes it controlled). I have a huge form with lots of checkboxes, but user can't change them! Probably I can use two-way data binding mixin, but docs suggest not to use them, so I'm stuck.

like image 915
user3702861 Avatar asked Oct 30 '14 15:10

user3702861


1 Answers

Use defaultChecked

Reference: https://reactjs.org/docs/uncontrolled-components.html#default-values

like image 113
Jak S Avatar answered Sep 26 '22 08:09

Jak S