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

ReactDOMServer.renderToString() recreates components tree from the scratch #42

Closed
limbosounds opened this issue Oct 15, 2018 · 1 comment

Comments

@limbosounds
Copy link

Hello!
Thank you for this awesome lib, really solves a lot of problem with SSR.

However, there is a little but very annoying trick. Assume I have walked through my application components tree, collected and upfilled all necessary data. When resolving a promise, in place where you wrote Now is a good time to call React's renderToString in example, I'm calling it and... see that renderToString starts to recreate all my components tree from the scratch. And it's okay if my data is stored in external storages, but those data that is inside the state is obviously being lost, because renderToString starts to call constructors again.

Can you, please, give me an advice, how to deal with this weird behaviour? Because I suppose that creating an external storage for every small view is not so good idea.

Thank you in advance and sorry for "stackoverflowing" in issues.

@limbosounds limbosounds changed the title ReactDOMServer.renderToString() recreates components tree from the stratch ReactDOMServer.renderToString() recreates components tree from the scratch Oct 19, 2018
@limbosounds
Copy link
Author

Okay, found the way. I'm writing data into static field and then use it as default value for state field :)
Your library is totally awesome!

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

1 participant