Filter Reset
Can I detect when a filter has been reset via
This is my ColumnDef
I need to reset the state of my filterOptions (array of options).
Any ideas?
3 Replies
wise-whiteOP•2y ago
If more code is needed I can provide it, just not sure about rules of posting lots of code.
I think ive managed to fix it, added to the header and then in the headerfilter component. Not sure if this is the best way and someone has a better way?
environmental-rose•2y ago
Not sure if this helps, but you can also check in a useEffect for the length of columnFilters this way:
Note, it doesn't specifically detect when the method
resetColumnFilters
has been called, but rather the abscence of any type of filter.robust-apricot•2y ago
Without reading much of the above, it sounds like you're attempting to handle some user triggered event, without treating it like a user triggered event, which is generally why you reach for useEffect, in the hope that it'll solve your problem. But it won't.
To take control of the filters you need to handle the resets and updates via user triggered updates to the state that you control.
This does not require a useEffect.