`
import React, {
ReactElement,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import { EditorState } from "draft-js";
import Editor, { createEditorStateWithText } from "@draft-js-plugins/editor";
import createInlineToolbarPlugin from "@draft-js-plugins/inline-toolbar";
import "../../../styles/editorStyles.css";
import "@draft-js-plugins/inline-toolbar/lib/plugin.css";
const text =
"In this editor a toolbar shows up once you select part of the text …";
Uncaught TypeError: _ref is undefined
this happens when i press delete key (<---)
const SimpleInlineToolbarEditor = (): ReactElement => { const [plugins, InlineToolbar] = useMemo(() => { const inlineToolbarPlugin = createInlineToolbarPlugin(); return [[inlineToolbarPlugin], inlineToolbarPlugin.InlineToolbar]; }, []);
const [editorState, setEditorState] = useState(() => createEditorStateWithText("") );
useEffect(() => { setEditorState(createEditorStateWithText(text)); }, []);
const editor = useRef<Editor | null>(null);
const onChange = (value: EditorState): void => { setEditorState(value); };
const focus = (): void => { editor.current?.focus(); };
return (
); };
export default SimpleInlineToolbarEditor; `