Skip to content

William-Gu/react-lazy-reload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React-Lazy-Reload

  • Reload regularly when the network is down

  • example:

import React, { Suspense } from 'react';
import {
  Route,
  Switch,
  Redirect,
} from 'react-router-dom';

import RouterLoader from "./utils/routerLoader.js";
const SuspenseBox = import('@/pages/SuspenseBox');

const List = lazy(() => import('@/pages/list'));

export default function () {
  return (
    <Suspense fallback={<SuspenseBox />}>
      <Switch>
        <Route exact path="/">
          <Redirect to="/list" />
        </Route>
        <Route path="/list" exact component={List} />
      </Switch>
    </Suspense>
  )
}
  • Contributions:
  1. Tushar Mohan
  2. Guilherme Oenning