-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
devtools: accessing serialize option #249
Comments
Thanks for opening this up! Anyone wants to investigate? |
This is kinda gross and not at all throughly tested, but to display Maps/Sets I used // zustand/middlware.js
var devtools = function devtools(fn, prefix) {
if (process.env.NODE_ENV !== 'production') {
if (!Map.prototype.toJSON) {
Map.prototype.toJSON = function() {
var obj = {};
this.forEach((value, key) => obj[key] = value);
return obj;
}
}
if (!Set.prototype.toJSON) {
Set.prototype.toJSON = function() {
return Array.from(this);
};
}
}
// ... the rest of the devtools middleware
} |
That's a nice hack. |
## Why is this change needed? Unable to display Maps/Sets ## How does it address the issue? optional serialize date, regex, undefined, nan, infinity, error, symbol, map & set ## breaking change prev "prefix" option prefix?: string -> options?: { name?: string } https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#serialize pmndrs#249
* Allow optional REDUX DEVTOOLS "options" object ## Why is this change needed? Unable to display Maps/Sets ## How does it address the issue? optional serialize date, regex, undefined, nan, infinity, error, symbol, map & set ## breaking change prev "prefix" option prefix?: string -> options?: { name?: string } https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#serialize #249 * backward compatible with "prefix" store name option * Update readme.md
* Allow optional REDUX DEVTOOLS "options" object ## Why is this change needed? Unable to display Maps/Sets ## How does it address the issue? optional serialize date, regex, undefined, nan, infinity, error, symbol, map & set ## breaking change prev "prefix" option prefix?: string -> options?: { name?: string } https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#serialize pmndrs/zustand#249 * backward compatible with "prefix" store name option * Update readme.md
Hello! I've just started using zustand, previously having used primarily redux. Big fan so far!
In setting up the
devtools
, I'm having trouble tying to configure the devtools. Specifically, I'm trying to enable theserialize
option, so that I can view aMap
in the tools nicely.Example of a store I'm trying to see with devtools:
In a redux configuration I would do this with:
Is there a similar way to access the devtool options from
zustand/middleware.devtools
?For anyone also facing this, my current solution is an old hack from redux before the
devTools.serialize
option:The text was updated successfully, but these errors were encountered: