-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getValue
cache not invalidating when accessorFn
is updated
#5363
Comments
Any updates on this? I'm seeing the same issue where a piece of state changes the value returned by the |
I'm seeing the same issue on my project. I suspect that it is caused by the following code table/packages/table-core/src/core/row.ts Lines 113 to 129 in 6d89e41
table/packages/table-core/src/utils/getCoreRowModel.ts Lines 9 to 48 in 6d89e41
Summary
I think there are some ways to fix the bug.
|
TanStack Table version
v8.12.0
Framework/Library version
React v18.2.0
Describe the bug and the steps to reproduce it
When the
accessorFn
for a column is updated to return a new value, the new value is never displayed in the table. Through a sophisticated series ofconsole.log
s, I discovered that whengetValue
is called on the rerender, the newaccessorFn
is never called, presumably due to caching on column id.The use case is a column that displays the name of the person for the current row. We want the user to be able to choose whether to display first or last name first (e.g.
Tanner Linsley
orLinsley, Tanner
). We could just change the column id when theaccessorFn
is updated, but then we lose the current sort state for that column, ie if the table is currently sorted by name, we want to stay sorted by name after the name format is changed.Steps to reproduce:
accessorFn
returns a different value based on some piece of stateYour Minimal, Reproducible Example - (Sandbox Highly Recommended)
https://stackblitz.com/edit/tanstack-table-rnjqkx?file=src%2Fmain.tsx
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
No, because I do not know how
Terms & Code of Conduct
The text was updated successfully, but these errors were encountered: