Skip to content

Commit 5a847d1

Browse files
j-piaseckiCopilot
andauthored
[General] Change Touchable callback order (#4126)
## Description Since #4116 is closed, this backports the part that changed the callback ordering. ## Test plan Verify that the order is `onPressIn` -> `onPressOut` -> `onPress`. --------- Co-authored-by: Copilot <copilot@github.com>
1 parent 67cdbb0 commit 5a847d1

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

  • packages/react-native-gesture-handler/src/v3/components/Touchable

packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,24 @@ export const Touchable = (props: TouchableProps) => {
8989
}
9090
}, []);
9191

92-
const onDeactivate = useCallback(
93-
(e: EndCallbackEventType) => {
94-
if (!e.canceled && !longPressDetected.current && e.pointerInside) {
95-
onPress?.(e);
96-
}
97-
},
98-
[onPress]
99-
);
100-
10192
const onFinalize = useCallback(
10293
(e: EndCallbackEventType) => {
10394
if (pointerState.current === PointerState.INSIDE) {
10495
onPressOut?.(e);
10596
}
10697

98+
if (!e.canceled && !longPressDetected.current && e.pointerInside) {
99+
onPress?.(e);
100+
}
101+
107102
pointerState.current = PointerState.UNKNOWN;
108103

109104
if (longPressTimeout.current !== undefined) {
110105
clearTimeout(longPressTimeout.current);
111106
longPressTimeout.current = undefined;
112107
}
113108
},
114-
[onPressOut]
109+
[onPressOut, onPress]
115110
);
116111

117112
const onUpdate = useCallback(
@@ -157,7 +152,6 @@ export const Touchable = (props: TouchableProps) => {
157152
enabled={!disabled}
158153
onBegin={onBegin}
159154
onActivate={onActivate}
160-
onDeactivate={onDeactivate}
161155
onFinalize={onFinalize}
162156
onUpdate={onUpdate}
163157
defaultOpacity={defaultOpacity}

0 commit comments

Comments
 (0)