fix: cannot update a component while rendering a different component (#1907)

This commit is contained in:
Himself65
2023-04-12 16:46:29 -05:00
committed by GitHub
parent 8f53043100
commit 2a2d682211

View File

@@ -41,6 +41,8 @@ const BlockSuiteEditorImpl = (props: EditorProps): ReactElement => {
if (editor.mode !== props.mode) {
editor.mode = props.mode;
}
useEffect(() => {
if (editor.page !== props.page) {
editor.page = props.page;
if (page.root === null) {
@@ -48,6 +50,8 @@ const BlockSuiteEditorImpl = (props: EditorProps): ReactElement => {
}
props.onLoad?.(page, editor);
}
}, [props.page, props.onInit, props.onLoad]);
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {