Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5e219c3

Browse files
committed
SimpleRichTextEditor: Always update _currentValue after setState (as long as contentState has changed)
1 parent fc0298d commit 5e219c3

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

‎src/SimpleRichTextEditor.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,16 @@ export default class SimpleRichTextEditor extends Component {
6666
let {format, onChange} = this.props;
6767
let oldEditorValue = this.state.editorValue;
6868
this.setState({editorValue});
69-
if (onChange == null) {
70-
return;
71-
}
7269
let oldContentState = oldEditorValue ? oldEditorValue.getEditorState().getCurrentContent() : null;
7370
let newContentState = editorValue.getEditorState().getCurrentContent();
7471
if (oldContentState !== newContentState) {
7572
let stringValue = editorValue.toString(format);
76-
// Optimization so when onChange passes us new props we don't need
73+
// Optimization so if we receive new props we don't need
7774
// to parse anything unnecessarily.
7875
this._currentValue = [format, stringValue];
79-
onChange(stringValue);
76+
if (onChange) {
77+
onChange(stringValue);
78+
}
8079
}
8180
}
8281
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /