feat(v2): better UX to avoid flashing screen on first page reload (#1100)

This commit is contained in:
Endilie Yacop Sucipto 2018-11-08 11:19:37 +08:00 committed by GitHub
parent fc7ba5b6b1
commit a0d229d808
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 />