Instantly share code, notes, and snippets.

@lixiaoyan /entry.js
Last active Dec 11, 2017

Embed
What would you like to do?
React 16: ReactDOM.hydrate(...)
import React from "react";
import ReactDOM from "react-dom";
import { AppContainer } from "react-hot-loader";
import App from "./App";
const render = (hydrate = false) => {
const container = document.querySelector("#app");
const element = (
<AppContainer>
<App />
</AppContainer>
);
if (hydrate) {
ReactDOM.hydrate(element, container);
} else {
ReactDOM.render(element, container);
}
};
render(true);
if (module.hot) {
module.hot.accept(() => {
render();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment