function UpdateStatePlugin(props) {
...
const [editor] = useLexicalComposerContext();
...
}
function Notes() {
...
const initialConfig = {
...
};
return (
<LexicalComposer initialConfig={initialConfig}>
...
<UpdateStatePlugin />
</LexicalComposer>
)
}
This fails with 'useLexicalComposerContext' is not defined
I followed this guide and found 1 mention of someone running into a similar problem here. In both cases the structure seems to resemble what I have written. Would appreciate any help!
It's ok to define
UpdateStatePlugin
in the same file. The important part is thatUpdateStatePlugin
needs to be a child ofLexicalComposer
.Your error,
'useLexicalComposerContext' is not defined
, looks like one you'd see if you were missing an import. Try adding this to the top of your file: