mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-08-15 18:45:06 +00:00
[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:
@@ -183,6 +183,7 @@ class TextInput extends Component<*> {
|
||||
blurOnSubmit,
|
||||
clearTextOnFocus,
|
||||
onChangeText,
|
||||
onLayout,
|
||||
onSelectionChange,
|
||||
onSubmitEditing,
|
||||
selection,
|
||||
|
||||
@@ -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() });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user