I am getting TypeError: o.a.createRef is not a function in react

568 views Asked by At

I am trying to add a open source Editor in my React project. I installed this using NPM. To quickly check wheather it is installed or not, i just did copy paste of code snippets from npm Website. Code

import React from 'react';
import 'codemirror/lib/codemirror.css';
import '@toast-ui/editor/dist/toastui-editor.css';
 
import { Editor } from '@toast-ui/react-editor';
 
class MyComponent extends React.Component {
  editorRef = React.createRef();
 
  handleClick = () => {
    this.editorRef.current.getInstance().exec('Bold');
  };
 
  render() {
    return (
      <>
        <Editor
          previewStyle="vertical"
          height="400px"
          initialEditType="markdown"
          initialValue="hello"
          ref={this.editorRef}
        />
        <button onClick={this.handleClick}>make bold</button>
      </>
    );
  }
}

Error

enter image description here

Version

"tsutils": "^3.17.1"
"react": "^16.13.1"
"react-dom": "^16.13.1"
"react-scripts": "3.4.1"
0

There are 0 answers