I have a few programatically generated lists of checkboxes (uncontrolled) in my project, and I'd like a react-way to clear them all at the click of a button. My problem is, I have no way to reference them each.
I've tried setting refs but I can't seem to figure out how to share refs between a stateless child and it's parent (is this even possible?)
All I need is a button that, when clicked, unchecks all checkboxes. I never would have imagined this would be so complicated but I've been at it for an hour now and my head is starting to spin. Here is an example of one of the lists:
{props.filters[0].map(jobType => (
<li key={_.uniqueId('subType_')} className="checkbox text-sm m-b-sm">
<label className="">
<input type="checkbox" value={jobType.value} name="subtype" onChange={props.handleFilterCheck} />
<span>{jobType.title}</span>
</label>
<span className="text-muted"></span>
</li>
))}
So I have a way to consistently reference the size of the list and I know I could use iteration if I just had a way to reference the list but as it stands now that isn't possible. Any ideas?