facebook / facebook/flow

nativeEvent in SyntheticTouchEvent may not have correct properties

Offen
#4,564 2 Kommentare 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
22.3k
Forks
1.9k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

When using [PanResponder](https://facebook.github.io/react-native/docs/panresponder.html) in react-native, an event of type _synthetic touch event_ is made available as a variable. This has a property `nativeEvent` with the following properties `identifier`, `locationX`, `locationY`, `pageX`, `pageY`, `target`, `timestamp`, `touches`. [`SyntheticTouchEvent` in flow](https://github.com/facebook/flow/blob/v0.52.0/lib/react.js#L383) does have a property `nativeEvent` (by inheritance), but this points to [`Event`](https://github.com/facebook/flow/blob/v0.52.0/lib/dom.js#L213) which does not contain all the properties mentioned in the PanResponder-docs. The PanResponder-docs does not seem in sync with the types flow have defined.

When looking at the [RN-code for places](https://github.com/facebook/react-native/blob/59e41b4485f9ee3ab10ac8c479089715ce02944b/Libraries/Inspector/InspectorOverlay.js#L45) where a similar event is used, it is made [an ad hoc solution](https://github.com/facebook/react-native/blob/59e41b4485f9ee3ab10ac8c479089715ce02944b/Libraries/Inspector/InspectorOverlay.js#L22):
```javascript
type EventLike {
nativeEvent: Object,
}

// ...
findViewForTouchEvent = (e: EventLike) => {
var {locationX, locationY} = e.nativeEvent.touches[0];
// ...
}
```

Does this mean that the _synthetic touch event_ mentioned in PanResponder-docs (or [Gesture Responder System](https://facebook.github.io/react-native/docs/gesture-responder-system.html#responder-lifecycle)-docs) is not the same as SyntheticTouchEvent mentioned in flow? Or is one of them not correct/up to date?

See example usage in [flow try](https://flow.org/try/#0AoQwdgSgpgzgDgezAEygJwHQGM1RAFygAoBvAKAAIKB6aijByipUSWRFdAWQQDcoAXBSJR+YfEIDKAT3EALKPgCWWACoIArljkBRMfgCUFALwA+CliQwEAGygYbCAOYj9GMASX89UcQ4RYnkgAGgZkAL4GANxkZLQUAIJYlmjISmBOFPgIWQoUyAEwADQUAERQpRRKMBQgFDCy+ArKWFma2hSivvgUAO5KTRQeyt76FHF0IDV1cGgIcOj40hiJKEOeo90UclO5UBSz84vSFI6ByiFCE9v4+HAwArQAZiBYUABGCAgA1hhOA3INO8MEoENRcK98ABaYZeKDUApYGDUODgXDwJCoTByfAAWxsQA).

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.