question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Side toolbar error: Uncaught TypeError: _this.props.store.getItem(...) is not a function

See original GitHub issue

Toolbar isn’t loading. And I get this error every keypress.

Error: Uncaught TypeError: _this.props.store.getItem(...) is not a function

Location: https://github.com/draft-js-plugins/draft-js-plugins/blob/master/draft-js-side-toolbar-plugin/src/components/Toolbar/index.js#L40

This is my source code:

import React, { Component } from 'react';
import Editor, { createEditorStateWithText } from 'draft-js-plugins-editor'; // eslint-disable-line import/no-unresolved
import createSideToolbarPlugin from 'draft-js-side-toolbar-plugin'; // eslint-disable-line import/no-unresolved
import 'draft-js-inline-toolbar-plugin/lib/plugin.css';
import 'draft-js-side-toolbar-plugin/lib/plugin.css';


// Sidebar toolbar
const sideToolbarPlugin = createSideToolbarPlugin();
const { SideToolbar } = sideToolbarPlugin;

// Plugins
const plugins = [
  sideToolbarPlugin,
];
const text = 'In this editor a toolbar shows up once you select part of the text …';

export default class CardEditor extends Component {

  state = {
    editorState: createEditorStateWithText(text),
  };

  onChange = (editorState) => {
    this.setState({
      editorState,
    });
  };

  focus = () => {
    this.editor.focus();
  };

  render() {
    return (
      <div onClick={this.focus}>
        <Editor
          editorState={this.state.editorState}
          onChange={this.onChange}
          plugins={plugins}
          ref={(element) => { this.editor = element; }}
        />
        <SideToolbar />
      </div>
    );
  }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12

github_iconTop GitHub Comments

11reactions
lineldcostacommented, Jun 22, 2017

Even i am facing the same issue!

7reactions
troelskncommented, Nov 3, 2017

I found the error. I had code where I would call createSideToolbarPlugin() inside the render() function of my component. This means a new plugin would be crated all the time. Moving const sideToolbarPlugin = createSideToolbarPlugin(); to the global scope solved this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A brand new website interface for an even better experience!
Side toolbar error : Uncaught TypeError: _this.props.store.getItem(...) is not a function.
Read more >
TypeError: getItem is not a function when testing a component ...
The test breaks at "productInCart = getItem(product.id)" saying " TypeError: getItem is not a function". I've been stuck at this for several ...
Read more >
Getting Data Out of the Redux Store with Selectors
A selector is a pure function that takes a state object from the Redux store and returns some information extracted from that state...
Read more >
"TypeError: _this.props.registeruser is not a function" : r/reactjs
The child component, PlayerRegistration, is where the problem resides. "componentDidMount()" shows the prop received is an empty object? huh?!?
Read more >
TypeError: is not a function in react Code Example
jQuery(document).ready(function($){ // jQuery code is in here }); ... Uncaught TypeError is not a function JavaScript. javascript by Attractive Anteater on ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found