-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Not working with react-redux-firebase "TypeError: Converting circular structure to JSON" #91
Comments
This library does not do anything specific with Firebase or serialization/deserialization of state. You can use custom serializer if needed: https:/kirill-konshin/next-redux-wrapper#custom-serialization-and-deserialization |
I'm experiencing this issue, with NextJS + next-redux-wrapper + react-redux-firebase. Several things involved here:
So what happens is NextJS tries to serialize the In that example - https:/zeit/next.js/tree/master/examples/with-redux - store is not passed to initial props, so I'm thinking that it probably shouldn't be done in the next-redux-wrapper either. Considering that Redux does not put any constraints on what you can put into the store, and NextJS clearly says that |
Nice explanation! Like I said before, you may add custom serializer/deserializer https:/kirill-konshin/next-redux-wrapper#custom-serialization-and-deserialization there you can do whatever you want with the store's state. |
It's not about serializing the state. State serializes just fine. It's about serializing store instance, that is being returned from Quote from NextJS: In this example https:/zeit/next.js/tree/master/examples/with-redux, store instance is not part of initial props, and it works fine. |
Got it. The difference is that Technically, we can get rid of this behavior. I need to do some research :) This is the discussion vercel/next.js#4295 (review) |
Fix #91 Not working with react-redux-firebase "TypeError: Converting circular structure to JSON" Updated dependencies
Published |
@kirill-konshin An other way to deal with this issue would be to make the store instance unserializable: store.toJSON = () => undefined; This is probably a bad idea (maybe someone would really want to serialize it?) but it can be used to keep the same store instance between EDIT: Or maybe you can wrap it in an unserializable object: const unserializableProps = { store };
unserializableProps.toJSON = () => undefined;
return {
unserializableProps,
isServer,
initialState: config.serializeState(store.getState()),
initialProps,
}; |
I tryed to use react-redux-firebase with next-redux-wraper and I ran into "TypeError: Converting circular structure to JSON" error.
This is also reported in react-redux-firebase repo and someone said the issue seems to be solved by creating withRedux HOC but there is no clear answer about the cause of issue and solution.
So, I was wodering if you can deal with this probrem.
bug(firebase): firebase error "TypeError: Converting circular structure to JSON"
prescottprue/react-redux-firebase#230
example of redux-wrapper HOC.
https://gist.github.com/artisin/d56750d955ff4a60ed11e6a714cbd1bd
`TypeError: Converting circular structure to JSON
at JSON.stringify ()
at module.exports (/Users/takuya/program/gaudiy-react-next/node_modules/htmlescape/htmlescape.js:24:15)
at NextScript.render (/Users/takuya/program/gaudiy-react-next/node_modules/next/dist/server/document.js:313:81)
at processChild (/Users/takuya/program/gaudiy-react-next/node_modules/react-dom/cjs/react-dom-server.node.development.js:2191:18)
at resolve (/Users/takuya/program/gaudiy-react-next/node_modules/react-dom/cjs/react-dom-server.node.development.js:2048:5)
at ReactDOMServerRenderer.render (/Users/takuya/program/gaudiy-react-next/node_modules/react-dom/cjs/react-dom-server.node.development.js:2333:22)
at ReactDOMServerRenderer.read (/Users/takuya/program/gaudiy-react-next/node_modules/react-dom/cjs/react-dom-server.node.development.js:2307:19)
at renderToStaticMarkup (/Users/takuya/program/gaudiy-react-next/node_modules/react-dom/cjs/react-dom-server.node.development.js:2690:25)
at _callee3$ (/Users/takuya/program/gaudiy-react-next/node_modules/next/dist/server/render.js:341:100)
at tryCatch (/Users/takuya/program/gaudiy-react-next/node_modules/regenerator-runtime/runtime.js:62:40)
at Generator.invoke [as _invoke] (/Users/takuya/program/gaudiy-react-next/node_modules/regenerator-runtime/runtime.js:296:22)
at Generator.prototype.(anonymous function) [as next] (/Users/takuya/program/gaudiy-react-next/node_modules/regenerator-runtime/runtime.js:114:21)
at step (/Users/takuya/program/gaudiy-react-next/node_modules/@babel/runtime/helpers/asyncToGenerator.js:12:30)
at _next (/Users/takuya/program/gaudiy-react-next/node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:9)
at
The text was updated successfully, but these errors were encountered: