Open eatyourgreens opened 6 years ago
Here, the text 'Hello World' cannot be changed in the editor.
<MarkdownEditor value={"Hello World"} />
Setting the value from component state and adding a change listener allows text to be edited:
class HelloWorld extends React.component {
constructor() {
this.state = {
value: 'Hello World'
};
}
onChange(e) {
const { value } = e.target;
this.setState({ value });
}
render() {
<MarkdownEditor
onChange={this.onChange.bind(this)}
value={this.state.value}
/>
}
}
The default change listener for the editor is
NOOP
, implying that it's optional. If you don't supply a change listener then the displayed text in the editor doesn't change when you type. In practice, you must supply a change listener, which updates the editor'svalue
prop on change.