From 53d18c83c8de220d3da5f30271a2e9a0765b8df2 Mon Sep 17 00:00:00 2001 From: Hedger Wang Date: Tue, 15 Dec 2015 17:31:07 -0800 Subject: [PATCH] Fix app crash caused by TextInput. Reviewed By: zjj010104 Differential Revision: D2761644 fb-gh-sync-id: 89241de2f8c84d569ec452871f740a0d655cc95e --- Libraries/Components/TextInput/TextInput.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index fe62ec7fb..62ff5f2a8 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -550,6 +550,12 @@ var TextInput = React.createClass({ this.props.onChange && this.props.onChange(event); this.props.onChangeText && this.props.onChangeText(text); + if (!this.refs.input) { + // calling `this.props.onChange` or `this.props.onChangeText` + // may clean up the input itself. Exits here. + return; + } + // This is necessary in case native updates the text and JS decides // that the update should be ignored and we should stick with the value // that we have in JS.