-
Notifications
You must be signed in to change notification settings - Fork 786
renderToStringWithData runs twice #1361
Comments
The same with |
Because of this, when I do SSR, I always get html between |
+1 |
Maybe this could be useful. For me this was happening because of not very obvious usage of Provider which is not only pass functionality or variables inside context but wrap component in another "util" component. And that's fine. So we have to use this |
@foxCanFly can you post an example? Maybe on https://codesandbox.io/? |
I have run into the same thing causing various weird unexpected behaviors in my app due to the duel render/constructors. This occurs because getDataFromTree and ReactDOM.renderToString both construct independent instances of the application. This can lead to really baffling behaviors if you try to build your ApolloClient instance inside of a React component instead of outside of the React app in your SSR code. Specifically it causes the SSR to fail because it builds up all of the data requests in getDataFromTree on the first render/constructor, but then it throws that app away and builds a new one in ReactDOM.renderToString with a fresh ApolloClient built in the constructors of the components again but now with none of the data from the initial tree traversal. |
Same issue here, reproduced at the issue is in the renderToStringWithData function
// the getDataFromTree will render the react component and then return the renderToString which renders again this is also shown on the Wiki
|
This should no longer be an issue with current day versions of |
@hwillson Can you elaborate on how this was fixed/improved? |
@mkochendorfer Sure thing; |
@hwillson Thanks for the extra context. |
Hi,
renderToStringWithData
is trying to render the supplied React element twice. Please check the below code and output. I am using node v8.9.0package.json
index.js
output
The text was updated successfully, but these errors were encountered: