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