We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For lists of checkboxes like this:
I like to store the IDs of the checked elements in a Set.
Set
To "toggle" a checkbox right now I have to do this:
checkOccasion = id => ev => { const spec = { enabled: { [ev.target.checked ? '$add' : '$remove']: [id], } }; this::updateState(spec); }
<CheckboxLabel value={occ.id} checked={enabled.has(occ.id)} onChange={this.checkOccasion(occ.id)}>{occ.name}</CheckboxLabel>
Would be nicer if instead I could just do:
const spec = { enabled: { $toggle: [id], } };
i.e. enabled is a Set, so if id is already contained in the set, it would be removed, otherwise it would be added.
enabled
id
Actually, alternatively $toggle could accept an object [too] which would explicitly let you add or remove specific elements:
$toggle
const spec = { enabled: { $toggle: { [id]: ev.target.checked }, } };
That'd let us skip the .has check too.
.has
The text was updated successfully, but these errors were encountered:
this suppots toogle on many props https://www.npmjs.com/package/immhelper
Sorry, something went wrong.
No branches or pull requests
For lists of checkboxes like this:
I like to store the IDs of the checked elements in a
Set
.To "toggle" a checkbox right now I have to do this:
Would be nicer if instead I could just do:
i.e.
enabled
is aSet
, so ifid
is already contained in the set, it would be removed, otherwise it would be added.Actually, alternatively
$toggle
could accept an object [too] which would explicitly let you add or remove specific elements:That'd let us skip the
.has
check too.The text was updated successfully, but these errors were encountered: