Skip to content

bug: useEditor returns null instead of Editor when it's not used in <EditorContent> #468

Open
@HamedMP

Description

@HamedMP

Provide environment information

System:
OS: macOS 15.1.1
CPU: (10) arm64 Apple M1 Pro
Memory: 116.63 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 21.2.0 - ~/.nvm/versions/node/v21.2.0/bin/node
Yarn: 1.22.22 - ~/.yarn/bin/yarn
npm: 10.8.1 - ~/.nvm/versions/node/v21.2.0/bin/npm
pnpm: 9.6.0 - ~/.nvm/versions/node/v21.2.0/bin/pnpm
bun: 1.1.0 - ~/.bun/bin/bun

Describe the bug

I described the bug and the workaround in this issue.


I had a menu bar from Tiptap component I used before but I couldn't get it to work as useEditor() doesn't return proper Editor instance.

I ended up using onCreate of Editor Contet and using a state to handle editor, then I can use my menu bar.

<EditorContent
extensions={extensions}

      onCreate={({ editor }) => {
        console.log("Editor created");
        setEditor(editor);
      }}
         ...
    >

I need editor in other parts as well but haven't found an easier/better way to do it than lifting up the state.

Link to reproduction

.

To reproduce

Try using useEditor in your project and log the results. Using useEffect didn't help either.

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions