About the best rerendering strategy
UmizDemud opened this issue · comments
Hi everyone, I had an issue which I found hard to solve. Can you help out?
How would I go about rerendering the Editor, when the state that holds its content changes. Please take a quick look on the below example. All I need is to update the editor when the component prop text updates.
...
const MyEditor = ({text}: {text: string}) => {
const editor: BlockNoteEditor = useBlockNote({
editable: true,
initialContent: (text as string).length !== 0 ? JSON.parse(text) as PartialBlock[] : undefined,
onEditorContentChange: (editor) => {
doSomething()
}
})
return (
<BlockNoteView
editor={editor}
theme={resolvedTheme === "dark" ? "dark" : "light"}
className=""
>
<FormattingToolbarPositioner editor={editor} />
<HyperlinkToolbarPositioner editor={editor} />
<SlashMenuPositioner editor={editor} />
</BlockNoteView>
)
}
P.S - Wonderful work with this product, I'd be more than happy to return and collab in the future!
Hi,
Your code sample seems from an old version, I'd recommend upgrading first and then file a new issue if you're still having trouble!