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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idea: forbid grabbing non draftables in strict mode #686
Labels
Comments
Gelio
added a commit
to Gelio/immer
that referenced
this issue
Dec 3, 2020
In strict mode, accessing a non-draftable property will throw One can use the unsafe function to perform such operations Fixes immerjs#686
Gelio
added a commit
to Gelio/immer
that referenced
this issue
Dec 3, 2020
In strict mode, accessing a non-draftable property will throw One can use the unsafe function to perform such operations Fixes immerjs#686
I tried to take a stab at implementing this in #715 |
Closed
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
馃殌 Feature Proposal
See #674 and many other issues where people are surprised that Immer by default totally ignores their class instances.
The idea is that if a field contains a non-draftable object, it becomes unreadable. E.g.:
produce(state, draft => { draft.buffer; })
would throw. To still use the buffer inside a draft, a explicit signal needs to be given, e.g.produce(state, draft => { mutableRef(draft.buffer).push(17); )
.Not sure about the name:
mutableRef
,unsafe
could all work. Or maybe we could even reuse the existingoriginal
method for this purpose, although that might be confusing.For easy backward compatibility an option
enableStrictMode(boolean)
could be used, by default off in the current version, and enabled in the next major.Can this be solved in user-land code?
No
The text was updated successfully, but these errors were encountered: