Last active
December 22, 2017 06:20
-
-
Save astrotim/1cd6696c516951239ae1fdb221c88712 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
-import ReactDOM from 'react-dom'; | |
+import { hydrate, render } from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
-import registerServiceWorker from './registerServiceWorker'; | |
-ReactDOM.render(<App />, document.getElementById('root')); | |
-registerServiceWorker(); | |
+const rootElement = document.getElementById('root'); | |
+if (rootElement.hasChildNodes()) { | |
+ hydrate(<App />, rootElement); | |
+} else { | |
+ render(<App />, rootElement); | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment