Reputation: 27
I think it might be silly question to ask but trust me I am new to ReactJS, I want to make a logic for checkbox . Actually, I have multiple checkbox in my program I want to save multiple check box value ( if user select ) in single State or Array . I tried hard but didn't find any proper solution . could someone please help me how to solve this problem .
Thanks
Upvotes: 0
Views: 65
Reputation: 82
Without knowing your code, I think the answer would be to create something like:
<input
type="checkbox"
checked={this.state.active}
onClick={this.handleClick}
/>
And then have the handleClick toggle a property of an object in memory (derived from state), and then call setState
using that object, to hold all of the tickbox values in a single state property.
Upvotes: 1