Skip to content

Instantly share code, notes, and snippets.

@astrotim astrotim/index.js.diff
Last active Dec 22, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.