Skip to content

Commit

Permalink
Guard against empy _inputRef in TextInput
Browse files Browse the repository at this point in the history
Reviewed By: cpojer

Differential Revision: D4420532

fbshipit-source-id: 6912c11b5a6f5d8efaa07dc7a09a9bc1cda0658a
  • Loading branch information
frantic authored and facebook-github-bot committed Jan 21, 2017
1 parent 5e9db57 commit 5a09b28
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,11 @@ const TextInput = React.createClass({
_onChange: function(event: Event) {
// Make sure to fire the mostRecentEventCount first so it is already set on
// native when the text value is set.
this._inputRef.setNativeProps({
mostRecentEventCount: event.nativeEvent.eventCount,
});
if (this._inputRef) {
this._inputRef.setNativeProps({
mostRecentEventCount: event.nativeEvent.eventCount,
});
}

var text = event.nativeEvent.text;
this.props.onChange && this.props.onChange(event);
Expand Down Expand Up @@ -824,7 +826,7 @@ const TextInput = React.createClass({
nativeProps.selection = this.props.selection;
}

if (Object.keys(nativeProps).length > 0) {
if (Object.keys(nativeProps).length > 0 && this._inputRef) {
this._inputRef.setNativeProps(nativeProps);
}

Expand Down

0 comments on commit 5a09b28

Please sign in to comment.