Fix onSelectionChange "this" binding

Reviewed By: tadeuzagallo

Differential Revision: D2660071

fb-gh-sync-id: 3fc50c0af8566dd7db5a56b220df979625673d07
This commit is contained in:
Nick Lockwood 2015-11-16 14:01:53 -08:00 committed by facebook-github-bot-4
parent e4f0971a55
commit 7aa789ad57
2 changed files with 6 additions and 1 deletions

View File

@ -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);
}}

View File

@ -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);