You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where I access the base state in an onSuccess callback of a mutation. Something along the lines of
create((base)=>{// Make changes to basemutation.mutate(...,{onSuccess: ()=>ctx.route.invalidate(base.id)})})
However, it seems like base is a proxy object that gets revoked at some point between the call to mutation.mutate() and the call to onSuccess(). Currently I'm copying the base into a separate object before every mutation like this
create((base)=>{// Make changes to basebase={ ...base}mutation.mutate(...,{onSuccess: ()=>ctx.route.invalidate(base.id)})})
but that is not ideal.
Is mutative actually passing a proxy object as base? If so, is this addressable on your end and/or are there any other workarounds I could use?
Note: this issue does not occur if running React in Strict Mode.
The text was updated successfully, but these errors were encountered:
@relsunkaev Mutative just drafts the baseState. I'm not sure how you're using it, but one thing is certain: the draft tree should not be used directly in any external function. You may encounter draft escaping, for example:
leta: any;conststate=create({a: {b: 1}},(draft)=>{draft.a.b=2;a=draft.a;});// Don't use 'a', 'a' is a draft.expect(()=>{JSON.stringify(a);}).toThrowError(`Cannot perform 'get' on a proxy that has been revoked`);// state.a is a object, not a draft
It would be helpful if you could provide a minimal example to help identify and troubleshoot the issue.
I have a use case where I access the
base
state in anonSuccess
callback of a mutation. Something along the lines ofHowever, it seems like base is a proxy object that gets revoked at some point between the call to
mutation.mutate()
and the call toonSuccess()
. Currently I'm copying the base into a separate object before every mutation like thisbut that is not ideal.
Is mutative actually passing a proxy object as
base
? If so, is this addressable on your end and/or are there any other workarounds I could use?Note: this issue does not occur if running React in Strict Mode.
The text was updated successfully, but these errors were encountered: