TypeError: _ref is undefined
AxtinM opened this issue · comments
Uncaught TypeError: _ref is undefined
this happens when i press delete key (<---)
`
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 …";
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 (
<Editor
editorKey="SimpleInlineToolbarEditor"
editorState={editorState}
onChange={onChange}
plugins={plugins}
ref={(element) => {
editor.current = element;
}}
/>
);
};
export default SimpleInlineToolbarEditor;
`
this happens when i press delete key (<---)
i solved it by adding
import { DraftailEditor } from "draftail";
and wrapping plugins Editor with DraftailEditor