I'm using Draft.js for a form I'm building on Next.js with TS, and I'm running into some errors. Here is my code:
import {Editor, EditorState} from 'draft-js';
const [editorState, setEditorState] = useState(
EditorState.createEmpty()
);
const editor = useRef<**WhatDoIUseHere**>(null);
function focusEditor() {
editor.current.focus();
}
useEffect(() => {
focusEditor()
}, []);
return (
<div onClick={focusEditor}>
<Editor
ref={editor}
editorState={editorState}
onChange={editorState => setEditorState(editorState)}
/>
</div>
)
What "tag" do I use for the 6th line? const editor... (null);
Thank you!
According to the source code:
HTMLDivElement
.const editor = useRef<HTMLDivElement>(null);
editorRef
, not ref
.<Editor
editorRef={editor}
// ...
/>