I want to update the Draft js Editor with some initial content. I know we can change EditorState
using component state.
import React from 'react';
import ReactDOM from 'react-dom';
import {Editor, EditorState} from 'draft-js';
class MyEditor extends React.Component {
constructor(props) {
super(props);
this.state = {editorState: EditorState.createEmpty()};
this.onChange = (editorState) => this.setState({editorState});
}
render() {
return (
<Editor editorState={this.state.editorState} onChange={this.onChange} />
);
}
}
Whenever I tried to change something in the Editor it's re rendering. This is causing some performance issue. Is there anyway I can set or change the Editor's state without changing the state. Something similar to this
EditorState.set(editorState); //here editorState is new editor state;
Any idea how to achieve?