From 7aa789ad573b4d0b3520a97f9c45665e735c05e5 Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Mon, 16 Nov 2015 14:01:53 -0800 Subject: [PATCH] Fix onSelectionChange "this" binding Reviewed By: tadeuzagallo Differential Revision: D2660071 fb-gh-sync-id: 3fc50c0af8566dd7db5a56b220df979625673d07 --- Examples/UIExplorer/TextInputExample.ios.js | 5 +++++ Libraries/Components/TextInput/TextInput.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Examples/UIExplorer/TextInputExample.ios.js b/Examples/UIExplorer/TextInputExample.ios.js index 92359b178..5f13d822f 100644 --- a/Examples/UIExplorer/TextInputExample.ios.js +++ b/Examples/UIExplorer/TextInputExample.ios.js @@ -75,6 +75,11 @@ var TextEventsExample = React.createClass({ onSubmitEditing={(event) => this.updateText( 'onSubmitEditing text: ' + event.nativeEvent.text )} + onSelectionChange={(event) => this.updateText( + 'onSelectionChange range: ' + + event.nativeEvent.selection.start + ',' + + event.nativeEvent.selection.end + )} onKeyPress={(event) => { this.updateText('onKeyPress key: ' + event.nativeEvent.key); }} diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 4e07f5620..a39362af1 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -414,7 +414,7 @@ var TextInput = React.createClass({ var onSelectionChange; if (this.props.selectionState || this.props.onSelectionChange) { - onSelectionChange = function(event: Event) { + onSelectionChange = (event: Event) => { if (this.props.selectionState) { var selection = event.nativeEvent.selection; this.props.selectionState.update(selection.start, selection.end);