fix: use startTransition (#1903)

This commit is contained in:
Himself65 2023-04-12 12:06:22 -05:00 committed by GitHub
parent 8bcef957fc
commit 6d5b101bb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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, useCallback } from 'react';
import { lazy, startTransition, useCallback } from 'react';
import { currentEditorAtom, workspacePreferredModeAtom } from '../atoms';
import { usePageMeta } from '../hooks/use-page-meta';
@ -73,14 +73,18 @@ export const PageDetailEditor: React.FC<PageDetailEditorProps> = ({
page={page}
onInit={useCallback(
(page: Page, editor: Readonly<EditorContainer>) => {
setEditor(editor);
startTransition(() => {
setEditor(editor);
});
onInit(page, editor);
},
[onInit, setEditor]
)}
onLoad={useCallback(
(page: Page, editor: EditorContainer) => {
setEditor(editor);
startTransition(() => {
setEditor(editor);
});
onLoad?.(page, editor);
},
[onLoad, setEditor]