Lexical version: 0.42.0 (but the bug is detected in the main branch as well)
Steps To Reproduce
- Mount Lexical with EditorRefPlugin attached, but without actually providing a ref
- Error occurs on this line
Link to code example:
(function ReactComponent(props) {
const ref = null;
// react component with lexical
<EditorRefPlugin editorRef={ref}/> // where ref is `null`
});
The current behavior
While the typescript docs mention null as input parameter
the typeof editorRef === "object" is missing a && editorRef !== null part.
The expected behavior
No crash on editorRef.current = editor; when editorRef === null
Impact of fix
Adding the null check fixes everything ;)
My current workaround
<EditorRefPlugin editorRef={ref || undefined }/>
Lexical version: 0.42.0 (but the bug is detected in the main branch as well)
Steps To Reproduce
Link to code example:
The current behavior
While the typescript docs mention null as input parameter
the
typeof editorRef === "object"is missing a&& editorRef !== nullpart.The expected behavior
No crash on
editorRef.current = editor;when editorRef === nullImpact of fix
Adding the null check fixes everything ;)
My current workaround
<EditorRefPlugin editorRef={ref || undefined }/>