-
Notifications
You must be signed in to change notification settings - Fork 262
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
SSR vs Browser results in different classnames and ReactDOM.hydrate mismatch :( #714
Comments
The hash should be deterministic. See and Do you have dynamic styles? The issue could also be due to the fact that you are hydrating multiple roots. Currently the styles registry is a singleton but there is a PR to enable multiple registries #703 |
@giuseppeg hmmm after digging deeper I discovered more... (I compared the strings being passed into the hashString function and the resultant hash) I realize that when I call flush it is actually passing a different string to the hashString function. When I inspect the strings using diff I realize that the css passed to hashString in the the build + babel transpilation process do not include the Above you can see a csv surrounded with quotations with columns Filename of styles, Resultant Hash, Input text
|
> Do you have dynamic styles? No I searched through the project and there are no dynamic styles.
@giuseppeg I changed it so they are both hydrating the same root, and it still happens. |
Bug
What is the current behavior?
Summary: I'm converting my site into a static generated site. I'm using
ReactDOMServer.renderToString
andflush from 'styled-jsx/server'
in a node.js pipeline to render the static assets. Then when the client runtime loads I am usingReactDOM.hydrate
to attempt to hydrate the application without a full render. Unfortunately it is re-rendering and a big white flash happens....I investigated by doing a diff on the HTML of my application without JavaScript enabled against the HTML after the ReactDOM.hydrate step occurs and the application is re-rendered. The only differences I see are the styled-jsx classnames being different... How are hashes being generated? Are they deterministic? Do they take into account logical components as well as dom-elements in their generation?
Is it possible to have the following output where everything is identical except for the styled-jsx classnames:
notice the class on the
.global-utility-navigation-wrapper
has the classjsx-3222006434
in the first example butjsx-2836309959
in the second example.This causes a mismatch and rerender when trying to rehydrate the page.
The text was updated successfully, but these errors were encountered: