fix: wrap React.lazy with Suspense (#1915)

This commit is contained in:
Himself65
2023-04-12 22:33:31 -05:00
committed by GitHub
parent 2bcda973d3
commit 6180a4c3cb
8 changed files with 138 additions and 120 deletions

View File

@@ -1,6 +1,6 @@
import { NoSsr } from '@mui/material';
import { useRouter } from 'next/router';
import { lazy } from 'react';
import { lazy, Suspense } from 'react';
import { StyledPage, StyledWrapper } from '../../layouts/styles';
import type { NextPageWithLayout } from '../../shared';
@@ -26,7 +26,9 @@ const InitPagePage: NextPageWithLayout = () => {
return (
<StyledPage>
<StyledWrapper>
<Editor onInit={initPage} testType={testType} />
<Suspense>
<Editor onInit={initPage} testType={testType} />
</Suspense>
<div id="toolWrapper" />
</StyledWrapper>
</StyledPage>

View File

@@ -11,7 +11,7 @@ import {
} from '@affine/workspace/affine/login';
import { useAtom } from 'jotai';
import type { NextPage } from 'next';
import { lazy, useMemo } from 'react';
import { lazy, Suspense, useMemo } from 'react';
import { toast } from '../../utils';
@@ -91,10 +91,12 @@ const LoginDevPage: NextPage = () => {
>
Check Permission
</Button>
<Viewer
theme={useTheme().resolvedTheme === 'light' ? 'light' : 'dark'}
value={user}
/>
<Suspense>
<Viewer
theme={useTheme().resolvedTheme === 'light' ? 'light' : 'dark'}
value={user}
/>
</Suspense>
</StyledWrapper>
</StyledPage>
);