TypeCellOS / BlockNote

A React Rich Text Editor that's block-based (Notion style) and extensible. Built on top of Prosemirror and Tiptap.

Home Page:https://www.blocknotejs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OnChange triggers infinite component reload

Anabel7213 opened this issue · comments

Describe the bug
After I type in "/" the component reloads every single time I try to type something.

To Reproduce
File A:
const onChange = (content: string) => {
update({
id: params.documentId,
content,
});
};

//...inside the return statement:

File B:
interface Editor {
onChange: (content: string) => void;
initialContent?: string;
editable?: boolean;
}
//...inside export:
const editor: BlockNoteEditor | null = useCreateBlockNote({
initialContent: initialContent ? (JSON.parse(initialContent) as PartialBlock[]) : undefined,
});
const saveToStorage = useCallback(() => {
if (onChange) {
setTimeout(() => {
onChange(JSON.stringify(editor.document));
}, 1000);
}
}, [onChange, editor.document]);

//...inside return:

      No errors are shown in the console