react#lazy TypeScript Examples

The following examples show how to use react#lazy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.tsx    From landy-react-template with MIT License 6 votes vote down vote up
Router = () => {
  return (
    <Suspense fallback={null}>
      <Styles />
      <Header />
      <Switch>
        {routes.map((routeItem) => {
          return (
            <Route
              key={routeItem.component}
              path={routeItem.path}
              exact={routeItem.exact}
              component={lazy(() => import(`../pages/${routeItem.component}`))}
            />
          );
        })}
      </Switch>
      <Footer />
    </Suspense>
  );
}
Example #2
Source File: root-router.tsx    From shippo with MIT License 6 votes vote down vote up
Component: React.FC<RootRouteProps> = ({ result }) => {
  const history = useNavigate()
  const location = useLocation()

  useMount(() => {
    console.log(result)
    const resource = result[0].data.resource
    localStorage.setItem('__PASSPORT', resource.passport)
    if (resource.uid > 0) {
      message.success(`已经登录,UID为${resource.uid}`)
      if (location.pathname.startsWith('/passport')) {
        history('/')
      }
    } else {
      message.error('没有登录')
      history('/passport')
    }
  })

  return (
    <Routes>
      <Route path="/passport" element={<Passport />}>
        <Route path="" element={<Page_passport />}></Route>
      </Route>
      <Route path="/dashboard" element={<Home />}>
        <Route path="" element={withLoading(lazy(() => import('~/pages/dashboard')))}></Route>
      </Route>
      <Route path="/read" element={<ReadLayout />}></Route>
      <Route path="/creation" element={<CreationLayout />}></Route>
      <Route path="*" element={<Navigate to="/dashboard" replace />}></Route>
    </Routes>
  )
}
Example #3
Source File: MiniDashboard.tsx    From yugong with MIT License 6 votes vote down vote up
MiniDashboard: React.FC = (props) => {
  // rootFontsize当成配合windowResize更新时组件做页面更新的key值,暂无实质用途
  const rootFontsize =
    useSelector((state: RootState) => state.controller.bestFont) || 16;
  // Memo缓存组件防止反复刷新
  // eslint-disable-next-line react-hooks/exhaustive-deps
  const LazyComponent = useMemo(
    () => lazy(() => import('~/components/MiniDashboard/Dashboard/index')),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [rootFontsize],
  );
  return (
    <Suspense fallback={<div>Loading...</div>}>
      <LazyComponent {...props} />
    </Suspense>
  );
}
Example #4
Source File: App.tsx    From argo-react with MIT License 5 votes vote down vote up
Login = lazy(() => import("./components/Login"))
Example #5
Source File: PageInfos.ts    From Cromwell with MIT License 5 votes vote down vote up
TagPage = lazy(() => import('../pages/tag/Tag'))
Example #6
Source File: routes.tsx    From one-platform with MIT License 5 votes vote down vote up
SwaggerToolboxPage = lazy(() => import('../pages/SwaggerToolboxPage'))
Example #7
Source File: PageInfos.ts    From Cromwell with MIT License 5 votes vote down vote up
ThemeEditPage = lazy(() => import('../pages/themeEdit/ThemeEdit'))
Example #8
Source File: root-router.tsx    From shippo with MIT License 5 votes vote down vote up
Component: React.FC<RootRouteProps> = ({ result }) => {
  const history = useNavigate()
  const location = useLocation()

  useMount(() => {
    console.log(result)
    const resource = result[0].data.resource
    localStorage.setItem('__PASSPORT', resource.passport)
    if (resource.uid > 0) {
      message.success(`已经登录,UID为${resource.uid}`)
      if (location.pathname.startsWith('/passport')) {
        history('/')
      }
    } else {
      message.error('没有登录')
      history('/passport')
    }
  })

  return (
    <Routes>
      <Route path="/passport" element={<Passport />}>
        <Route path="" element={<Page_passport />}></Route>
      </Route>
      <Route path="/transform" element={<Transform />}></Route>
      <Route path="/dashboard" element={<Home />}>
        <Route path="" element={withLoading(lazy(() => import('~/pages/dashboard')))}></Route>
      </Route>
      <Route path="/users" element={<Home />}>
        <Route path="" element={withLoading(lazy(() => import('~/pages/users')))}></Route>
      </Route>
      <Route path="/temp/*" element={<Home />}>
        <Route
          path="temp_trade_20220108"
          element={withLoading(lazy(() => import('~/pages/temp/temp_trade_20220108')))}
        ></Route>
      </Route>
      <Route path="/permission/*" element={<Home />}>
        <Route
          path="role"
          element={withLoading(lazy(() => import('~/pages/permission/role')))}
        ></Route>
        <Route
          path="access"
          element={withLoading(lazy(() => import('~/pages/permission/access')))}
        ></Route>
        <Route
          path="policy"
          element={withLoading(lazy(() => import('~/pages/permission/policy')))}
        ></Route>
      </Route>
      <Route path="*" element={<Navigate to="/dashboard" replace />}></Route>
    </Routes>
  )
}
Example #9
Source File: AppRouter.tsx    From react-tutorials with MIT License 5 votes vote down vote up
MyPage = lazy(() => import('./pages/MyPage/MyPage'))
Example #10
Source File: App.tsx    From generator-earth with MIT License 5 votes vote down vote up
Standard = lazy(()=>import('./containers/Standard/'/* webpackChunkName:"Standard" */))
Example #11
Source File: AppRouter.tsx    From Tiquet with MIT License 5 votes vote down vote up
AuthCallback = lazy(() => import('../pages/AuthCallback'))
Example #12
Source File: App.tsx    From cards-against-formality-pwa with BSD 2-Clause "Simplified" License 5 votes vote down vote up
Homepage = lazy(() => import('./components/Homepage/Homepage'))
Example #13
Source File: InviteSignup.tsx    From posthog-foss with MIT License 5 votes vote down vote up
PasswordStrength = lazy(() => import('../../lib/components/PasswordStrength'))
Example #14
Source File: App.tsx    From interface-v2 with GNU General Public License v3.0 5 votes vote down vote up
DragonPage = lazy(() => import('./pages/DragonPage'))
Example #15
Source File: App.tsx    From argo-react with MIT License 5 votes vote down vote up
SignUp = lazy(() => import("./components/SignUp"))
Example #16
Source File: index.tsx    From react-micro-frontends with MIT License 5 votes vote down vote up
Main = lazy(() => import('../pages/Main'))
Example #17
Source File: App.tsx    From glide-frontend with GNU General Public License v3.0 5 votes vote down vote up
RemoveLiquidity = lazy(() => import('./views/RemoveLiquidity'))
Example #18
Source File: index.tsx    From genshin-optimizer with MIT License 5 votes vote down vote up
WeaponEditor = lazy(() => import('./WeaponEditor'))
Example #19
Source File: index.tsx    From reskript with MIT License 5 votes vote down vote up
Create = lazy(() => import('../Create'))
Example #20
Source File: App.tsx    From platform with MIT License 5 votes vote down vote up
Page404 = lazy(() => import("./pages/Error/404"))
Example #21
Source File: App.tsx    From argo-react with MIT License 5 votes vote down vote up
SignupWorkflows = lazy(() => import("./components/SignupWorkflows"))
Example #22
Source File: PageInfos.ts    From Cromwell with MIT License 5 votes vote down vote up
TagListPage = lazy(() => import('../pages/tagList/TagList'))
Example #23
Source File: App.tsx    From argo-react with MIT License 5 votes vote down vote up
UserSettings = lazy(() => import("./components/UserSettings"))
Example #24
Source File: index.tsx    From react-loosely-lazy with Apache License 2.0 5 votes vote down vote up
ReactLazy = lazy(
  () => import(/* webpackChunkName: "async-react-lazy" */ './ui/react-lazy')
)
Example #25
Source File: LogViewer.tsx    From backstage with Apache License 2.0 5 votes vote down vote up
RealLogViewer = lazy(() =>
  import('./RealLogViewer').then(m => ({ default: m.RealLogViewer })),
)
Example #26
Source File: GlobalRoutes.tsx    From nodestatus with MIT License 5 votes vote down vote up
LayoutHandler = lazy(() => import('../containers/LayoutHandler'))
Example #27
Source File: index.tsx    From react-micro-frontends with MIT License 5 votes vote down vote up
Main = lazy(() => import('../pages/Main'))
Example #28
Source File: App.tsx    From raspiblitz-web with MIT License 5 votes vote down vote up
LazySettings = lazy(() => import("./pages/Settings"))
Example #29
Source File: App.tsx    From aws_serverless_photo_gallery with MIT License 5 votes vote down vote up
PictureDialog = lazy(() => import('./PictureDialog'))