我正在使用来自useEditor库的TipTap函数来创建一个编辑器,但它首先返回null。我的意思是,如果我使用useEditor并立即记录我设置的变量,它将返回null,但它随后返回一个Editor对象。我用的是创建-反应-应用程序。
我的App.js文件中有这样的内容:
const editorUse = useEditor({
extensions: [StarterKit],
content: JSON.parse(localStorage.getItem("text")) ?? "",
});
console.log(editorUse);上面印着这个:

代码沙箱:https://codesandbox.io/s/zealous-darwin-iswww?file=/src/App.js
发布于 2022-09-25 10:00:03
您必须添加以下行
if(!editor) {
return null;
}
return (
<>
<EditorContent editor={editor} />
</>
);文件中也提到了这一点。提示反应医生
https://stackoverflow.com/questions/70057834
复制相似问题