Skip to content
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

Map show up as empty object in redux devtools #683

Closed
steinarb opened this issue Aug 7, 2020 · 3 comments
Closed

Map show up as empty object in redux devtools #683

steinarb opened this issue Aug 7, 2020 · 3 comments

Comments

@steinarb
Copy link

steinarb commented Aug 7, 2020

See the issue reduxjs/redux-devtools#496

Map shows up as empty object (i.e. "{}") in redux devtools.

The rationale for getting it working again (i.e. it used to work and no longer works, and Map is a very useful datatype to use), is here: reduxjs/redux-devtools#496 (comment)

The suggested fix/workaround is to set up serialize in the redux-devtools options: reduxjs/redux-devtools#496 (comment)

But since setting up redux-devtools is handled inside redux-toolkit, I need redux-toolkit to do it.

Is it possible to have redux-toolkit set up redux-devtools so that Map will show up?

@steinarb
Copy link
Author

steinarb commented Aug 7, 2020

I was able to set serialize to true using the devTools parameter to configureStore, like so:

const store = configureStore({
    reducer: createRootReducer(history),
    middleware: [
        sagaMiddleware,
        routerMiddleware(history),
    ],
    devTools: { serialize: { options: true } },
});

So what I'm arguing for now, is that the default should be to set up devtools with serialize set to true (I understand there may be performance considerations).

@phryneas
Copy link
Member

phryneas commented Aug 7, 2020

We explicitly recommend against using objects that cannot be trivially reserialized using JSON.parse in the store, as this does not only need extra configuration of the devtools, but might also cause all kinds of problems with third-party middlewares like redux-persist and for everything except Map and Set also with immer.

So enabling this by default would probably send a wrong signal ;)

@markerikson
Copy link
Collaborator

markerikson commented Aug 7, 2020

We have always specifically told users to never put non-serializable values like classes and Maps into the Redux store, exactly for this reason. Use of Maps in the store also will likely lead to bugs where your UI does not re-render properly, because React-Redux relies on reference checks to determine if values have changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants