#Best way to use checkbox table

2 messages · Page 1 of 1 (latest)

slim ember
#

I have a global table component with react table checkboxes (child component). I want to use it on a page (parent component) and save the selectedFlatRows in the parent state.

this is how I update the state from my table component

useEffect(() => {
if(selectedFlatRows && selectedFlatRows.length) onSelectChange(selectedFlatRows.map(row => row.original))
}, [selectedFlatRows]);

But when a parent state changes, the table rerenders too. And it's going to reset the selection.

Is there a way to use the checkbox table from the child component and save it to the parent state without reset? I have tried react memo but it's not working

cold notch
#

I am also facing the same issue