sstur / draft-js-utils

DraftJS: import/export ContentState to and from HTML/Markdown
ISC License
883 stars 234 forks source link

editorState.getCurrentContent is not a function #202

Open invious opened 4 years ago

invious commented 4 years ago
import {stateFromHTML} from 'draft-js-import-html';

class RichEditor extends React.Component {
    constructor({article}) {
        console.log(article)
        super(article);
        this.state = {editorState: EditorState.createEmpty()};
        console.log(article)
        if (article){
            this.setState(stateFromHTML(article.body));
        }

image

matiishyn commented 4 years ago

same issue here

raymond-ong commented 4 years ago

Initially, i ran to this prob too. I realized i should call stateFromHTMLfrom inside EditorState.createWithContent()

EditorState.createWithContent(stateFromHTML("<div><h1>I'm an H1 Tag</h1></div>"))

paperkotter commented 3 years ago

@raymond-ong thanks it works