Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Toolbar has no editor! on app refresh #207

Open
Ulthran opened this issue Oct 21, 2021 · 2 comments
Open

Error: Toolbar has no editor! on app refresh #207

Ulthran opened this issue Oct 21, 2021 · 2 comments

Comments

@Ulthran
Copy link

Ulthran commented Oct 21, 2021

Running the code in Example.

Any time I would save changes and refresh the app while on the screen with the rich editor (through Metro bundler, but I don't think this problem is specific to that), I would get the below errors and usually would have to rebuild the app to make it responsive again:

ERROR TypeError: _reactNative.Keyboard.removeListener is not a function. (In '_reactNative.Keyboard.removeListener('keyboardDidShow', this.onKeyShow)', '_reactNative.Keyboard.removeListener' is undefined)

This error is located at:
...
ERROR Error: Toolbar has no editor!
ERROR Error: Toolbar has no editor!

Found a similar issue here with a solution that solved this problem as well.

Need to change:

componentDidMount() {
        Appearance.addChangeListener(this.themeChange);
        Keyboard.addListener('keyboardDidShow', this.onKeyShow);
        Keyboard.addListener('keyboardDidHide', this.onKeyHide);
    }

    componentWillUnmount() {
        Appearance.removeChangeListener(this.themeChange);
        Keyboard.removeListener('keyboardDidShow', this.onKeyShow);
        Keyboard.removeListener('keyboardDidHide', this.onKeyHide);
    }

to:

componentDidMount() {
        this.changeListenerSub = Appearance.addChangeListener(this.themeChange);
        this.keyShowSub = Keyboard.addListener('keyboardDidShow', this.onKeyShow);
        this.keyHideSub = Keyboard.addListener('keyboardDidHide', this.onKeyHide);
    }

    componentWillUnmount() {
        this.changeListenerSub?.remove();
        this.keyShowSub?.remove();
        this.keyHideSub?.remove();
    }

Looks as though removeListener was removed from RN in a recent update. Easy fix though.

@KrisLau
Copy link

KrisLau commented Apr 28, 2022

#203 (comment)
Might help

@ashishAmz
Copy link

App is crashing and getting same message "Error: Toolbar has no editor!" while initializing the Component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants