运行代码时遇到错误“无法读取未定义的属性‘getIn’”。有谁知道如何解决这个问题。
如何重现: 只需写“aa”
这是我的代码:
import React from "react";
import { Editor, EditorState } from "draft-js";
import "draft-js/dist/Draft.css";
import Head from "next/head";
export default function MyEditor() {
const [editorState, setEditorState] = React.useState(() =>
EditorState.createEmpty()
);
const editor = React.useRef(null);
function focusEditor() {
editor.current.focus();
}
return (
<>
<Head>
<meta charset="utf-8" />
</Head>
<div
style={{ border: "1px solid black", minHeight: "6em", cursor: "text" }}
onClick={focusEditor}
>
<Editor
ref={editor}
editorState={editorState}
onChange={setEditorState}
placeholder="Write something!"
/>
</div>
</>
);
}
谢谢您的帮助。
我找到了解决办法,你可以试试我的方法
//just use dynamic import
const Editor = dynamic(() => import("draft-js").then((mod) => mod.Editor), {
ssr: false,
});