Yarin Nim Yarin Nim - 1 year ago 499
React JSX Question

How to set default Checked in checkbox REACT js

I'm having trouble to update the checkbox state after it's assigned with default value checked="checked" in React.

var rCheck = React.createElement('input',{type: 'checkbox', checked:'checked', value: true},'Check here');

after assigning
, I cannot interact the checkbox state by clicking to uncheck/check.

Answer Source

If the checkbox is created only with React.createElement then the property defaultChecked is used.

React.createElement('input',{type: 'checkbox', defaultChecked: false});

Credit to @nash_ag

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download