Toggling the checkboxes is not working when calling a function within the handelOnPress function!
See original GitHub issueHey @WrathChaos ,
I have a Flatlist
that has some BouncyCheckbox components.
const handelWorkToDo = (service, isChecked) => {
if (isChecked) {
console.log('add service');
setWorkToDo([...workToDo, service]);
} else {
console.log('remove service');
const isAvailable = (item) => item.id === service.id;
R.filter(isAvailable, workToDo);
}
};
const Service = ({ id, title, duration }) => (
<BouncyCheckbox
fillColor="red"
iconStyle={{ borderColor: 'red' }}
key={id}
onPress={(isChecked) =>
handelWorkToDo({ id, title, duration }, isChecked)
}
style={{ paddingBottom: 10 }}
text={`${title} -> ${duration}`}
textStyle={{
textDecorationLine: 'none',
}}
/>
);
const renderItem = ({ item }) => <Service {...item} />;
<FlatList
data={DATA}
renderItem={renderItem}
keyExtractor={(item) => item.id}
style={{ padding: 2 }}
/>
Whats happening is that when when I call the setWorkToDo([...workToDo, service])
or R.filter(isAvailable, workToDo)
within the handelWorkToDo
function, checkbox state is not being changed.
however if I remove/comment out those functions, the checkboxes are being checked without issues.
I would like to know if there is something missing within my code or If you have a fix for that.
Thank you 😃
Issue Analytics
- State:
- Created a year ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Checkbox toggle content section not working for all checkboxes
I have created 4 checkbox toggle with details but ...
Read more >How To Use Checkboxes In Google Sheets - Ben Collins
Learn how to use the Google Sheets checkbox to toggle cells checked/unchecked in your Google Sheets and make them more interactive.
Read more >ARIA: checkbox role - Accessibility - MDN Web Docs - Mozilla
The checkbox role is for checkable interactive controls. ... two states ("checked" or "not checked"), with an indeterminate state settable ...
Read more >React Tutorial – How to Work with Multiple Checkboxes
Whenever we click on the checkbox the handleOnChange handler function will be called which we use to set the value of isChecked state....
Read more >How to handle HTML checkbox events | HTML Form Guide
There are two events that you can attach to the checkbox to be fired once the checkbox value has been changed they are...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @WrathChaos ,
Thanks for the quick reply!
I had to do some work around for it to work as expected however it would be nice to support that within ur lib.
I took a look into the Manual check state and I saw that you are using one checkbox to toggle on/off with a useState hook. It would be nice to have an example of using multiple checkboxes that can toggle them with useState hook.
Thank you 😃
So, I was able to run it and just created a PR for my changes. Please take a look here and let me know your thoughts 😃