6

I'm using the useEditor function from the TipTap library to create an editor, but it returns null at first. What I mean is, if I used useEditor and immediately logged the variable I set it to, it returns null, but it returns an Editor object afterwards. I'm using React with create-react-app.

I have this in my App.js file:

const editorUse = useEditor({
    extensions: [StarterKit],
    content: JSON.parse(localStorage.getItem("text")) ?? "",
  });
  console.log(editorUse);

It prints out this: error image

Code sandbox: https://codesandbox.io/s/zealous-darwin-iswww?file=/src/App.js

Neesh
  • 143
  • 2
  • 3
  • 13

1 Answers1

0

You have to add the following line

  if(!editor) {
    return null;
  }
  
  return (
    <>
      <EditorContent editor={editor} />
    </>
  );

This is also mentioned in the document. Tiptap react doc