I've created a JSfiddle
In this fiddle, initially a list of checkboxes is rendered based on the props which are passed to the component.
On clicking the Re-render button, the same component is rendered with a different set of props.
Now, please follow the below steps-
- Load the jsfiddle
- Check any of the checkbox (let's say I check the 2nd and 3rd checkbox)
- Click
Re-renderbutton
Even after rendering the component with new props, the state of checked boxes which you checked remains unchanged (2nd and 3rd are still checked)
Why does it happen? How can I re-render the component with new set of props such that the state of checkboxes do not persist.
checkedproperty usingthis.setState. Using if statements works but is not reacty. Here's a fiddle of this as an example: jsfiddle.net/jwm6k66c/1034