Fix TouchableOpacity onPressStart with React 17

React 17 changed something that means the dispatchConfig is not included in
synthetic events.

Fix #1833
This commit is contained in:
Nicolas Gallagher
2020-12-03 12:41:09 -08:00
parent a877a02beb
commit 366f0e9923

View File

@@ -88,7 +88,11 @@ function TouchableOpacity(props: Props, forwardedRef): React.Node {
onLongPress,
onPress,
onPressStart(event) {
setOpacityActive(event.dispatchConfig.registrationName === 'onResponderGrant' ? 0 : 150);
const isGrant =
event.dispatchConfig != null
? event.dispatchConfig.registrationName === 'onResponderGrant'
: event.type === 'keydown';
setOpacityActive(isGrant ? 0 : 150);
if (onPressIn != null) {
onPressIn(event);
}