mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-18 06:47:02 +08:00
fix: wrap React.lazy with Suspense (#1915)
This commit is contained in:
@@ -5,7 +5,7 @@ import { useBlockSuiteWorkspacePageTitle } from '@toeverything/hooks/use-blocksu
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import Head from 'next/head';
|
||||
import type React from 'react';
|
||||
import { lazy, startTransition, useCallback } from 'react';
|
||||
import { lazy, startTransition, Suspense, useCallback } from 'react';
|
||||
|
||||
import { currentEditorAtom, workspacePreferredModeAtom } from '../atoms';
|
||||
import { usePageMeta } from '../hooks/use-page-meta';
|
||||
@@ -64,32 +64,34 @@ export const PageDetailEditor: React.FC<PageDetailEditorProps> = ({
|
||||
>
|
||||
{header}
|
||||
</WorkspaceHeader>
|
||||
<Editor
|
||||
style={{
|
||||
height: 'calc(100% - 52px)',
|
||||
}}
|
||||
key={pageId}
|
||||
mode={isPublic ? 'page' : currentMode}
|
||||
page={page}
|
||||
onInit={useCallback(
|
||||
(page: Page, editor: Readonly<EditorContainer>) => {
|
||||
startTransition(() => {
|
||||
setEditor(editor);
|
||||
});
|
||||
onInit(page, editor);
|
||||
},
|
||||
[onInit, setEditor]
|
||||
)}
|
||||
onLoad={useCallback(
|
||||
(page: Page, editor: EditorContainer) => {
|
||||
startTransition(() => {
|
||||
setEditor(editor);
|
||||
});
|
||||
onLoad?.(page, editor);
|
||||
},
|
||||
[onLoad, setEditor]
|
||||
)}
|
||||
/>
|
||||
<Suspense>
|
||||
<Editor
|
||||
style={{
|
||||
height: 'calc(100% - 52px)',
|
||||
}}
|
||||
key={pageId}
|
||||
mode={isPublic ? 'page' : currentMode}
|
||||
page={page}
|
||||
onInit={useCallback(
|
||||
(page: Page, editor: Readonly<EditorContainer>) => {
|
||||
startTransition(() => {
|
||||
setEditor(editor);
|
||||
});
|
||||
onInit(page, editor);
|
||||
},
|
||||
[onInit, setEditor]
|
||||
)}
|
||||
onLoad={useCallback(
|
||||
(page: Page, editor: EditorContainer) => {
|
||||
startTransition(() => {
|
||||
setEditor(editor);
|
||||
});
|
||||
onLoad?.(page, editor);
|
||||
},
|
||||
[onLoad, setEditor]
|
||||
)}
|
||||
/>
|
||||
</Suspense>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user