devtools with option serialize.immutable
does not deserialize state from devtools correctly (broken redux devtools "Jump" / "Revert" etc.)
#2561
Unanswered
JayFoxRox
asked this question in
Bug report
Replies: 1 comment 5 replies
-
@JayFoxRox Thanks for reporting! |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
redux-devtools provides a
serialize
option: https://github.com/reduxjs/redux-devtools/blob/main/extension/docs/API/Arguments.md#serialize.You can provide the
immutable-js
library to theserialize.immutable
field to: "automatically serialize/deserialize immutablejs via remotedev-serialize."This works fine for serializing: redux-devtools will show
ImmutableSet
if zustand store was created with this option.However, it breaks with deserializing during
JUMP_TO_ACTION
,REVERT
and other devtools options, when used with zustand.With zustand, the state doesn't get deserialized correctly, so the next time the store is used, the code will receive the wrong data type.
This problem does not occur with redux.
I believe this should work:
serialize
option was added in Allow optional REDUX DEVTOOLS "options" object #540 by @marcoSvenLink to reproduction
https://github.com/JayFoxRox/zustand/tree/immutable-bug/examples/demo
All changes are in this commit: JayFoxRox@80f0765
specifically, this is using:
My reproduction is based on the zustand demo.
To show the problem, the number counter has been replaced by a growing
Immutable.Set
.To display it, I
JSON.stringify
theImmutable.Set
(Immutable handles JSON stringification, so it shows as array).The demo creates 2 stores; one for redux and one for zustand; each with devtools.
The counter button has been duplicated:
The stores both work until the devtools are used to jump.
When jumping, the redux store continues to work, but the zustand store breaks.
Once the state is broken, JSON stringification shows a JS object which represents the serialized JSON encoding in the redux-devtools.
Here's a video:
zustand-devtools-bug.mp4
Check List
Please do not ask questions in issues.
Please include a minimal reproduction.
Please check this if you're filing an issue regarding TypeScript.
create
is to be used ascreate<T>()(...)
and notcreate<T>(...)
.Beta Was this translation helpful? Give feedback.
All reactions