sstur / react-rte

Pure React rich text WYSIWYG editor based on draft-js.
https://react-rte.org
ISC License
2.86k stars 430 forks source link

TypeError: Cannot read property 'getEditorState' of undefined #364

Closed kalideir closed 4 years ago

kalideir commented 4 years ago

Hi everyone,

I've found this library and tried to integrate this component into a Reactjs-based dashboard I am working on, as a side project.

Although I have used the exact same component from the documentation, I am getting the error message:

TypeError: Cannot read property 'getEditorState' of undefined

import React from 'react';
import RichTextEditor from 'react-rte'

class TextEditor extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            value: RichTextEditor.createEmptyValue(),
        }
    }

    onChange = (value) => {
        this.setState({ value: RichTextEditor.createValueFromString(value, 'html') });
    };

    render() {
        return (
            <RichTextEditor
                editorState={this.state.value}
                onChange={this.onChange}
            />
        );
    };
}

export default TextEditor;