-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Allow providing custom JSON stringify functions in SSR state serialization #6614
Comments
Currently there's no way around this. I suggest "normalizing" your data structure with something like https://github.com/paularmstrong/normalizr Another solution would be to provide an API to customize the stringifying function so that you can use something like https://github.com/WebReflection/circular-json or https://github.com/yyx990803/circular-json-es6 (note you'd also need to use them to parse the stringified state on the client) |
@yyx990803 thanks for reply. I'd like to use the second But there is no API to use custom stringify function to serialize initial state? I found it uses So I'm eager for your suggestion for using the |
Closed via 4494012 |
Version
2.3.4
Reproduction link
https://jsfiddle.net/mapleeit/dnh0zpy8/
Steps to reproduce
SSR will use
JSON.stringify
method stringify initial state towindow.__INITIAL_STATE__
but this initial state has circular quote which will throw error like
TypeError: Converting circular structure to JSON
Is there any way to avoid this, or only thing I can do is to remove this circular state?
What is expected?
use something like [Circular] to avoid throwing error
What is actually happening?
TypeError: Converting circular structure to JSON
It's not convenient to make minimal reproduction on JSFiddle because of the webpack step.
The text was updated successfully, but these errors were encountered: