-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
DataTable: sortFunction retains stale data #2249
Comments
This is a repeat of #1705 with an updated codesandbox. Don't know why you'd want duplicates, but here it is. |
Hi, I think this is related to demo. In the last phase, the value is [7, 8, 9] in DataTable component. But, it is [4,5,6] in your createSortFunc and old value remains in callback. Please try; Best Regards, |
@mertsincan Also as I stated in #1705:
Maybe even change it to be a predicate. So that the sortFunction wouldn't be able to replace data at all. |
And you can't even do that with a functional component, since you don't have Functional version of my reproducer: https://codesandbox.io/s/primereact-datatable-sortfunction-retains-stale-data-updated-2-ykv5w |
This is fixed in 8.2.0 |
I'm submitting a ... (check one with "x")
Codesandbox Case (Bug Reports)
https://codesandbox.io/s/primereact-datatable-sortfunction-retains-stale-data-updated-u5esv
Current behavior
A custom sortFunction is not passed in data, so you have to keep track of it yourself. But even though my sortFunction gets recreated with new data, the sortFunction instance that ends up being used is old and remembers stale data.
Expected behavior
The recreated up-to-date sortFunction instance is used for sorting.
Minimal reproduction of the problem with instructions
Open linked codesandbox.
Click the "New data" button.
Observe the table showing updated data.
Now click the table header to enable sorting.
Click the "New data" button.
Observe the table showing stale data.
In the sandbox console you can see that createSortFunc was called with up-to-date data, yet the sortFunction that got invoked after that rememberd stale data.
Please tell us about your environment:
17.0.2
6.5.1
The text was updated successfully, but these errors were encountered: