Convert/clone state (Proxy) into Object #553
-
I'm trying to extract some state and do a copy of it to do some modifications independently from the proxy. If I use strucutredClone the browser throws an error. How can we do a deep copy of a part of the state? It doesn't need to be a Proxy, I just need the object content of it. |
Beta Was this translation helpful? Give feedback.
Answered by
santiagopuentep
Sep 22, 2022
Replies: 2 comments 2 replies
-
const state = proxy({ obj: ... })
snapshot(state.obj) // will create a plain object very efficiently, but it's frozen
import { cloneDeep } from 'lodash'
cloneDeep(state.obj) // will probably do without freezing |
Beta Was this translation helpful? Give feedback.
0 replies
-
So using |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
santiagopuentep
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So using
snapshot()
can be used safely to "unproxy" objects? Without calling reactivity on the fields (like it happens when accessinguseSnapshot
's object).