[fix] onLayout event object

Make sure that `this` within the `target` getter references the React
component rather than the layout event object.

Fix #996
This commit is contained in:
Nicolas Gallagher
2018-06-14 13:21:25 -07:00
parent 47a281373a
commit 90bd23f783
2 changed files with 6 additions and 4 deletions
@@ -183,6 +183,7 @@ class TextInput extends Component<*> {
blurOnSubmit,
clearTextOnFocus,
onChangeText,
onLayout,
onSelectionChange,
onSubmitEditing,
selection,
+5 -4
View File
@@ -131,11 +131,12 @@ const applyLayout = Component => {
) {
this._layoutState = { x, y, width, height };
const nativeEvent = {
layout: this._layoutState,
get target() {
return findNodeHandle(this);
}
layout: this._layoutState
};
Object.defineProperty(nativeEvent, 'target', {
enumerable: true,
get: () => findNodeHandle(this)
});
onLayout({ nativeEvent, timeStamp: Date.now() });
}
}