Skip to content

Commit 366f0e9

Browse files
committed
Fix TouchableOpacity onPressStart with React 17
React 17 changed something that means the dispatchConfig is not included in synthetic events. Fix #1833
1 parent a877a02 commit 366f0e9

File tree

1 file changed

+5
-1
lines changed
  • packages/react-native-web/src/exports/TouchableOpacity

1 file changed

+5
-1
lines changed

packages/react-native-web/src/exports/TouchableOpacity/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ function TouchableOpacity(props: Props, forwardedRef): React.Node {
8888
onLongPress,
8989
onPress,
9090
onPressStart(event) {
91-
setOpacityActive(event.dispatchConfig.registrationName === 'onResponderGrant' ? 0 : 150);
91+
const isGrant =
92+
event.dispatchConfig != null
93+
? event.dispatchConfig.registrationName === 'onResponderGrant'
94+
: event.type === 'keydown';
95+
setOpacityActive(isGrant ? 0 : 150);
9296
if (onPressIn != null) {
9397
onPressIn(event);
9498
}

0 commit comments

Comments
 (0)