mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-15 18:17:35 +02:00
feat(v2): better UX to avoid flashing screen on first page reload (#1100)
This commit is contained in:
parent
fc7ba5b6b1
commit
a0d229d808
1 changed files with 4 additions and 3 deletions
|
@ -6,15 +6,16 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import Loadable from 'react-loadable';
|
||||
import {BrowserRouter} from 'react-router-dom';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
import App from './App';
|
||||
import preload from './preload';
|
||||
import routes from '@generated/routes'; // eslint-disable-line
|
||||
|
||||
// Client side render (e.g: running in browser) to become single-page application (SPA)
|
||||
if (typeof document !== 'undefined') {
|
||||
Loadable.preloadReady().then(() => {
|
||||
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
||||
preload(routes, window.location.pathname).then(() => {
|
||||
ReactDOM.render(
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue