Putting dom reference into store will cause lag #2079
Unanswered
MilesLeeeeee
asked this question in
Bug report
Replies: 2 comments
-
|
Can anyone look into this? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
It should because of the {
name: "bear",
stateSanitizer: (state) => {
return JSON.parse(
JSON.stringify(state, (_key, value) => {
if (typeof value === "function") return undefined;
if (value instanceof HTMLElement)
return `${value.tagName} ${value.className}`;
if (value instanceof Date) return value.toLocaleString();
return value;
})
);
},
}
The root cause should be related to facebook/react#24360 HTMLElement.prototype.toJSON = () => "{}"; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hello
I tried putting the dom reference into the store to make it easier for me to use, but I found that it made the browser lag.
I tested in three browsers
chrome:117
edge:117
firefox:116
Chrome and edge are experiencing serious lags
firefox runs fine
Is there something wrong with my operation or should I not put the dom reference into the store?
Link to reproduction
https://codesandbox.io/s/zustand-dom-test-d7g4l3?file=/src/App.js
You can see the difference by changing the comment on this line
Beta Was this translation helpful? Give feedback.
All reactions