-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
updateMany
ignores early updates if later updates have the same ID
#619
Comments
Yeah, I think this is an actual bug. Here's the offending bit of code: redux-toolkit/src/entities/unsorted_state_adapter.ts Lines 106 to 117 in 9a410e7
The issue is that the updates are nested in I'm busy atm, but I'd happily take a PR and some unit tests to fix this. |
Thanks for taking a look, @markerikson. I've opened PR #621 to fix it. |
I am using redux-toolkit v1.7.0 and I am still experiencing issues with several updates of the same id. I experience the reverse problem of what is described in the example above, the first update for the id takes effect but not the following. |
@karlsoderback if you're seeing problems, could you file a new issue with a CodeSandbox or a project that reproduces the problem? (fwiw we haven't changed any of this behavior since this issue was closed.) |
I tried to reproduce the issue that @karlsoderback reported here, but it appears to be working fine, or at least working as expected. |
Thanks for your replies, I'll put together a reproducer as soon as I can! |
I refactored the sandbox provided by @jakeboone02 here to closer reflect my project where the issue is experienced. In this example you should see the effect I described. |
@karlsoderback If you're actually seeing a bug, please open up a new issue so we can keep track of it. |
@karlsoderback When I remove the @markerikson I can't tell what's going on here because the |
new issue please :) |
Posted in new issue: #1853 |
The
updateMany
action generated by thecreateEntityAdapter
function is not working as intended when there are multiple updates to the same entity.Consider the following code:
The outcome of that last statement should be that entity
1
has a title of "New Title 1" and a new author of "New Author 1". But what actually happens is that theauthor
is changed but not the title.The docs say, "If
updateMany()
is called with multiple updates targeted to the same ID, they will be merged into a single update, with later updates overwriting the earlier ones." That's a little ambiguous. It could mean that the later updates should be merged with earlier updates (not conflicting if the fields are different), or that the later updates would completely replace earlier updates with the same ID. It's doing the latter, but should do the former.See the codesandbox here:
https://codesandbox.io/s/redux-toolkit-updatemany-test-verzl?file=/src/App.tsx
The text was updated successfully, but these errors were encountered: