更新日期:2020年09月02日 投稿作者:分类目录网 围观人数:12402



react-snap一个零配置的静态 SPA 单页应用预渲染框架。


yarn add --dev react-snap


"scripts": {
  "postbuild": "react-snap"


import { hydrate, render } from "react-dom";

c***t rootElement = document.getElementById("root");
if (rootElement.hasChildNodes()) {
  hydrate(<App />, rootElement);
} else {
  render(<App />, rootElement);

react-snap react-snap_无需配置的预渲染单页应用 第1张 react-snap_无需配置的预渲染单页应用 第2张 react-snap_无需配置的预渲染单页应用 第3张

Pre-renders web app into static HTML. Uses headless chrome to pre-render. Crawls all available links starting from the root. Heavily inspired by prep and react-snapshot , but written from scratch. Uses best practices to get best loading performance.

Does not depend on React . The name is inspired by react-snapshotand because the initial goal was to enable seamless integration with create-react-app. Actually, it works with any technology. C***idering to change the name.


  • Enables SEO (google, duckduckgo...) and SMO (twitter, facebook...) for SPA.
  • Works out-of-the-box with create-react-app - no code-changes required.
  • Uses real browser behind the scene, so no issue with unsupported HTML5 features, like WebGL or Blobs.
  • Crawls all pages starting from the root, no need to list pages by hand, like in prep.
  • With prerendered HTML and inlined critical CSS you will get fast first paint, like with critical .
  • With Preload resourcesfeature you will get faster first interaction time if your page does do AJAX requests.
  • Works with webpack 2 code splitting feature
  • Handles sourcemaps

Please note: some features are experimental, but basic prerendering is c***idered stable enough. API is subject to change before freeze in version 1.0.

Basic usage with create-react-app


yarn add --dev react-snap

Change package.json:

" scripts " : {  " build " : " react-scripts build && react-snap " }

Change src/index.js(for React 16+):

import { hydrate , render } from  ' react-dom ' ; c***t rootElement = document . getElementById ( ' root ' );  if ( rootElement . hasChildNodes ()) {  hydrate ( < App / > , rootElement);  } else { render ( < App / > , rootElement);  }      

That's it!



BT Kitty 专注于提供BT种子搜索和下载的网站,你可以在这里搜索和下载电影、剧集、音乐、图书、图片、综艺、软件、动漫、教程、游戏等资源,BT Kitty 可以说算得上一款BT种子搜索神器、下载利器。 BT Library 索引了几千万千万BT种子,包括电影、剧


电脑怎么设置开机密码:   相信很多人都有不想给别人乱上自己的电脑的想法吧?电脑怎么设置开机密码呢?那么设置电脑开机密码是最好的办法了。如何设置开机密码?简单几步就能设置好咯!这里来演示一下XP系统和win7系统的开机密码设置方法。   除以上系统外,还将给大家带来windows10系统开机密码的设置方法


电脑没有声音怎么办?其实原因无非就2个,电脑硬件问题与软件问题。硬件问题主要是声卡坏了,或者输出声音接口损坏等,一般声卡硬件损坏很少,软件问题是比较常见的导致电脑没声音。那么如何判断是硬件问题还是软件问题呢?下面来分条详细说明。  一般处理电脑故障我们都是先软件后硬件的。如果您的电脑没有声音请尝试以下解决办法,一般是可以解决的. 电脑没有声音怎么办