-
Notifications
You must be signed in to change notification settings - Fork 19
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
Modification inside create is lost and differs from immer #18
Comments
hi @Gongreg , it's an issue with the finalization draft process, and I am fixing it. |
hi @Gongreg , I've fixed the issue and I've released the latest version 0.7.0. Immer has the following issue. import { produce } from 'immer';
import { create } from 'mutative';
const baseState = {
array: [
{
one: {
two: {
three: 3,
},
},
},
],
};
const created = create(baseState, (draft) => {
draft.array[0].one.two.three = 2;
const two = draft.array[0].one.two;
const one = new Set();
draft.array = [{ one }];
one.add(two);
expect(Array.from(draft.array[0].one)[0].three).toBe(2);
});
expect(Array.from(created.array[0].one)[0].three).toBe(2); // it's ok
const produced = produce(baseState, (draft: any) => {
draft.array[0].one.two.three = 2;
const two = draft.array[0].one.two;
const one = new Set();
draft.array = [{ one }];
one.add(two);
expect(Array.from(draft.array[0].one)[0].three).toBe(2);
});
// throw error
expect(() => Array.from(produced.array[0].one)[0].three).toThrowError(
`Cannot perform 'get' on a proxy that has been revoked`
); Thank you so much for reporting this issue. |
Thanks for fixing! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello.
I've noticed part of user written code that used to work with immer does not work with mutative. Here is code snippet:
Curious to hear is this expected?
The text was updated successfully, but these errors were encountered: