After I type in “/” the component re-renders every single time I try to type something, making it unusable.
File A:
const update = useMutation(api.documents.updateDocument);
const onChange = (content: string) => {
update({
id: params.documentId,
content,
});
};
<Editor onChange={onChange} initialContent={document.content} />
File B:
const editor: BlockNoteEditor | null = useCreateBlockNote({
initialContent: initialContent
? (JSON.parse(initialContent) as PartialBlock[])
: undefined,
});
const uploadToDatabase = useCallback(() => {
if (onChange) {
setTimeout(() => {
onChange(JSON.stringify(editor.document));
}, 1000);
}
}, [editor, onChange]);
<BlockNoteView
onChange={uploadToDatabase}
editable={editable}
editor={editor}
theme={resolvedTheme === "dark" ? "dark" : "light"}
/>
What am I doing wrong? There aren’t any errors in the console. Thanks for any help!
I tried using editor.topLevelBlocks which is deprecated now so I used editor.document instead, and now with each symbol I type in the component reloads.