Replies: 4 comments 1 reply
-
I found a way to do it:
It works, but I do consider it a bit of a hack, especially because it requires a deep comparison of the state to avoid an infinite loop of dispatch and re-render. I am still looking for help into how this could be better achieved, and will leave the thread unanswered. |
Beta Was this translation helpful? Give feedback.
-
Hey @89erik! I am running into a kinda similar issue. Basically, I am using Since I don't have control over Although, the way I am currently tackling this issue is by triggering an effect which calls that callback whenever the selected rows have changed. Not sure if this is the right way to do this but I feel like this is more similar to a "side-effect" rather than a reducer's job to call a callback (reducers are pure functions so you won't expect a side effect or a function call there) Do let me know if you have found a solution for this or have any feedback over the proposed solution! Cheers |
Beta Was this translation helpful? Give feedback.
-
I keep the user’s filter settings and sort options in a local Jan pretty much disavows it now, but it’s simple and works well if you are doing it for a React component that is not used more than once in your app. Just update the |
Beta Was this translation helpful? Give feedback.
-
Hi @89erik , I have implemented redux to store the pageIndex value as i am using multiple instances of react table, as i want to maintain state for each react table. When i click on next page i dispatch an action to store the pageIndex value in reducer. When i navigate to second page and if i apply global filter then the pageCount shows 2 of 1. The pageIndex is set to 1, and doesn't update on filtering the values. codesandbox - https://codesandbox.io/s/relaxed-chebyshev-4r3up?file=/src/App.js react-table version : 7.7.0 |
Beta Was this translation helpful? Give feedback.
-
Hi.
I'd like to have all the column header inputs in my table as one big controlled component (using redux) so that filter values and sortings don't disappear when navigating around my application. I cannot figure out from the documentation and examples how to do this. The examples all seem to focus on pagination, which you would render yourself as one controlled component, and then feed the page value into the table. Filter values and sort order, however, are more hidden away in the framework. The button for changing sort order for example is made as such <span {...column.getSortByToggleProps()}>, and I cannot see any clean way of making these into controlled components.
The FAQ suggests using "useControlledState", which seems like exactly what I am looking for: A way to get called on state changes so that it can be dispatched to redux, and then feed my own state from redux into the table. This however, only seems to support the latter. I am basically looking for an onStateChange callback function or similar so that I can put all state changes into redux, and feed the state directly from redux into the table, like so:
How do I do this?
Beta Was this translation helpful? Give feedback.
All reactions