fix: useEffect

This commit is contained in:
DiamondThree
2022-12-20 15:29:24 +08:00
parent 2bf44326f3
commit f2210bbe79
9 changed files with 91 additions and 72 deletions
@@ -35,10 +35,10 @@ const Home: NextPage = () => {
return ret;
}
const editor = createEditor(page);
const editor = createEditor?.current?.(page);
if (editor) {
editorContainer.current?.appendChild(editor);
setEditor(editor);
setEditor?.current?.(editor);
if (page.isEmpty) {
const title = 'Welcome to the AFFiNE Alpha';
const pageId = page.addBlock({
@@ -53,7 +53,7 @@ const Home: NextPage = () => {
}
return ret;
}, [workspace, page]);
}, [workspace, page, createEditor, setEditor]);
return (
<>
@@ -19,13 +19,13 @@ const Page = () => {
return;
}
createPage()?.then(async pageId => {
createPage?.current?.()?.then(async pageId => {
if (!pageId) {
return;
}
router.push(`/workspace/${currentWorkspaceId}/${pageId}`);
});
}, [workspace, currentWorkspaceId]);
}, [workspace, currentWorkspaceId, createPage, router]);
return <div>Hello, there is [pageId]/index</div>;
};