valtio/v2/deep-clone-proxy-objects
No description available
In Valtio v2, the behavior of the `proxy(obj)` function has changed. In v1, `proxy(obj)` was a pure function that deeply copied the object `obj`. In v2, `proxy(obj)` is an impure function that deeply modifies `obj`. This codemod updates your code to accommodate these changes by incorporating `deepClone` to ensure that objects are deeply copied as they were in v1.
## Example
### Before
```ts
import { proxy } from 'valtio';
const state = proxy({ count: 1, obj: { text: 'hi' } });
state.obj = { text: 'hello' };
```
### After
```ts
import { proxy } from 'valtio';
import { deepClone } from 'valtio/utils';
const state = proxy(deepClone({ count: 1, obj: { text: 'hi' } }));
state.obj = deepClone({ text: 'hello' });
```