Closed Gongreg closed 10 months ago
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!
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?