-
-
Notifications
You must be signed in to change notification settings - Fork 852
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
produceWithPatches creates patch when assigning a reference to itself #648
produceWithPatches creates patch when assigning a reference to itself #648
Comments
Per documentation, the patches generated by Immer are correct, but not necessarily the smallest patch possible. Will update the docs to reflect that. |
If you don't mind checking this patch: #690 It seems to solve the issue example codesandbox The only issue I see with the tests is handling the |
🎉 This issue has been resolved in version 8.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
edit: nevermind, it actually has been fixed 🎉 |
@smirea so the PR wasn't a fix for this issue? |
oh i completely missed that it got merged, sorry about that. just tested it on 8.0.2 and it works fine, thank you 🎉 |
🐛 Bug Report
When using
produceWithPatches
, if you mutate a reference and then assign it to itself, the resulting patch would be a replace on the parent, instead of a replace on the nested fieldLink to repro
Example: https://codesandbox.io/s/immer-issue-producewithpatches-nested-change-assign-to-self-vmd5l?file=/src/index.ts
To Reproduce
Observed behavior
The above returns a single patch of:
Expected behavior
It should not count assigning a reference to itself as a replace and just ignore it. The correct patch should be:
Environment
Tested on 7.0.7
setUseProxies(true)
setUseProxies(false)
(ES5 only)Full Example
The text was updated successfully, but these errors were encountered: