Skip to content

Commit

Permalink
Add extra info
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored Oct 23, 2017
1 parent 05b118a commit 7e48614
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions content/docs/reference-react-dom.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ React expects that the rendered content is identical between the server and the

If you intentionally need to render something different on the server and the client, you can do a two-pass rendering. Components that render something different on the client can read a state variable like `this.state.isClient`, which you can set to `true` in `componentDidMount()`. This way the initial render pass will render the same content as the server, avoiding mismatches, but an additional pass will happen synchronously during mounting. Note that this approach will make your components slower because they have to render twice, so use it with caution.

Remember to be mindful of user experience on slow connections. The JavaScript code may load significantly later than the initial HTML render, so if you render something different in the client-only pass, the transition can be jarring. However, if executed well, it may be beneficial to render a "shell" of the application on the server, and only show some of the extra widgets on the client. To learn how to do this without getting the markup mismatch issues, refer to the explanation in the previous paragraph.

* * *

### `unmountComponentAtNode()`
Expand Down

0 comments on commit 7e48614

Please sign in to comment.