immerjs / immer

Create the next immutable state by mutating the current one
https://immerjs.github.io/immer/
MIT License
27.65k stars 848 forks source link

When ImmerJS processes objects containing Symbol keys, the Symbols become Proxies. #1096

Closed Wxh16144 closed 7 months ago

Wxh16144 commented 7 months ago

🙋‍♂ Question

Hello everyone,

I recently started using ImmerJS and encountered a challenging issue. In my data structure, there is a property with a key as Symbol, which is only used for querying purposes and will not be modified when using ImmerJS. Specifically, I try to query and modify certain data through v[S1].id.

However, when outputting the result in the console, I noticed that although the corresponding value was successfully modified, strangely my Symbol key S1 was converted into a Proxy object. This has left me feeling very confused and frustrated.

Could you please let me know if this is a known bug or behavior caused by some boundary conditions? If anyone can provide an explanation or point to relevant documentation/discussion links, I would greatly appreciate it. Thank you all!

image

Link to repro

Please provide a CodeSandbox demo to clarify your question if possible. Typically, questions without minimal codesandbox demo won't be answered.

Environment

We only accept questions against the latest Immer version.

version: "immer": "^10.0.2"

github-actions[bot] commented 7 months ago

:tada: This issue has been resolved in version 10.0.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket: