扫一扫分享
react-snap一个零配置的静态 SPA 单页应用预渲染框架。
react-snap安装
yarn add --dev react-snap
package.json:
"scripts": {
"postbuild": "react-snap"
}
src/index.js:
import { hydrate, render } from "react-dom";
const rootElement = document.getElementById("root");
if (rootElement.hasChildNodes()) {
hydrate(<App />, rootElement);
} else {
render(<App />, rootElement);
}
手机预览