Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

React Table - useRowSelect change select all default behavior

Writer Andrew Henderson

I am using the selection hook in my react table and I can't find a way to override the select all checkbox behavior. When the select all checkbox is checked if you uncheck a specific row in the table it turns the isAllRowsSelected to false.

I want it to change only if the header checkbox is clicked, because I want to be able to have a state that says "all results, except the unmarked ones".

I am using server side pagination so I can't rely only on the selectedRowIds array. This is the implementation of useRowSelect I used : here

2

1 Answer

You can add this line, it trigers on component mount.

React.useEffect(()=> {toggleAllRowsSelected()},[])

All code like this: codesandbox

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.