Nee*_*esh 6 reactjs create-react-app tiptap
我正在使用useEditorTipTap 库中的函数来创建编辑器,但它首先返回 null。我的意思是,如果我使用useEditor并立即记录我设置的变量,它会返回 null,但随后会返回一个 Editor 对象。我正在使用 React 和 create-react-app。
我的 App.js 文件中有这个:
const editorUse = useEditor({
extensions: [StarterKit],
content: JSON.parse(localStorage.getItem("text")) ?? "",
});
console.log(editorUse);
Run Code Online (Sandbox Code Playgroud)
代码沙箱:https://codesandbox.io/s/zealous-darwin-iswww?file =/src/App.js
小智 0
您必须添加以下行
if(!editor) {
return null;
}
return (
<>
<EditorContent editor={editor} />
</>
);
Run Code Online (Sandbox Code Playgroud)
文档中也提到了这一点。 Tiptap 反应文档
| 归档时间: |
|
| 查看次数: |
2143 次 |
| 最近记录: |