facebook / facebook/flow

nativeEvent in SyntheticTouchEvent may not have correct properties

Abierto
#4,564 2 comentarios 3 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
22.3k
Forks
1.9k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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).

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.