Replies: 5 comments 15 replies
-
I think what it receives is a function, so:
I got confused by this as well for a while but this is how I made it work with a reducer instead of a state, no idea why it works directly with a state setter but not with other states like a reducer |
Beta Was this translation helpful? Give feedback.
-
You should be sending the updater to something that can apply it correctly, but if you really want to get the new value yourself, you can use table's exported const newValue = functionalUpdate(updater, oldValue) |
Beta Was this translation helpful? Give feedback.
-
It's very confusing how sorting change event works took me good 30 mins to understand this. |
Beta Was this translation helpful? Give feedback.
-
I would really hope this would get better documentation. Costed me a while until I found this thread and the solutions within. What would've helped me was just a short snippet with how to get the I eventually came up with the following:
and when implementing:
☝️ the trick was calling the We have this wrapped in our own React-component, so wanted to manage our own state outside of the table - instead of having a |
Beta Was this translation helpful? Give feedback.
-
this is my very easy solution to just getting the updated value in order for me to save it to the cloud for a saved preference
all you have to do is supply the existing state from your useState in this case [ sorting, setSorting ] = useState() and then add to your tanstack table options i was really confused when i console logged x for a while, but it works if you give it the correct previous state value |
Beta Was this translation helpful? Give feedback.
-
I am attempting to pass functions to a component so I can add them to
useTableInstance
, but I seem to be missing something here:When done this way, I cannot seem to get the value. I am aware that the documented way is to use the direct
useState
setter function, but that's not always going to be the use case. For example, I'm trying to set the value in a Storybook story:While I do get a value, it always seems to be the old value, and Typescript screams at me that
val
is not a function.So what would be the proper way to get the standalone value here? Would it potentially make more sense to simply pass the value to these functions rather than an updater so that the user can have more control?
Beta Was this translation helpful? Give feedback.
All reactions