From 366f0e9923adbcfb24bf512e9d5434e0a76b8127 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Thu, 3 Dec 2020 12:41:09 -0800 Subject: [PATCH] Fix TouchableOpacity onPressStart with React 17 React 17 changed something that means the dispatchConfig is not included in synthetic events. Fix #1833 --- .../react-native-web/src/exports/TouchableOpacity/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-native-web/src/exports/TouchableOpacity/index.js b/packages/react-native-web/src/exports/TouchableOpacity/index.js index c3dffb86..c7ff1932 100644 --- a/packages/react-native-web/src/exports/TouchableOpacity/index.js +++ b/packages/react-native-web/src/exports/TouchableOpacity/index.js @@ -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); }