Closed janjaap closed 5 years ago
In my component's constructor:
this.props.statusList.forEach((status) => { // statusList is an array of objects with props 'key' and 'value' filterForm.get('sstate').push(FormBuilder.control(status)); });
Hey, it seems like a typo, sstate
should be state
.
Let me know if doesn't resolve the issue, a code sandbox link with the issue will be more helpful to debug.
Was definitely a typo. I'll set up a sandbox.
Link to the sandbox: https://codesandbox.io/s/young-morning-gv0ss?fontsize=14
I see. I was hoping the result would be similar to what FormData
would provide, but I guess this'll work too. Thanks.
Right, but it won't create the controls automatically. If you wanna use some automatic stuff with less code, you can try FormGenerator API.
I've been looking through the documentation as wel as the examples and the source code, but there's something I can't figure out and that is how to have a group of checkboxes that I can all check or uncheck by the click of a button.
I have the following:
In my component's constructor:
And in my
render()
function:Two issues here:
onClick
handler that I want to toggle all of the boxes doesn't seem to work with React'suseState
hookHow can I solve both issues mentioned? Feedback greatly appreciated.