Reputation: 35
So I have very specific issues. I have checkbox with controlled component and it works fine on local machine, but when I push code online, then everything works (check/uncheck), data are ok "0" and "1", but checkbox is always checked. Anyone knows what might be cause of problem?
https://gist.github.com/sasafister/3f6d555432986a74e37f113685720a6d
Here is my code
<input className="float-right" type="checkbox" defaultChecked={course.is_featured} onChange={this.toggleChecked.bind(this, course.id)} />
Upvotes: 0
Views: 390
Reputation: 7774
If you are using a controlled input you must have value/checked
and onChange
handler. defaultChecked
is for initial load and not updatable.
<input className="float-right" type="checkbox" checked={course.is_featured} onChange={this.toggleChecked.bind(this, course.id)} />
Upvotes: 1