Skip to content

Commit 69eb9d9

Browse files
committed
New Pressable
1 parent 4c43ecc commit 69eb9d9

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,18 @@ const PressableWithTouchable = (props: PressableProps) => {
284284
}
285285
: undefined;
286286

287+
// `testOnly_pressed` forces the pressed state (for snapshots/tests) and can
288+
// change after mount, so derive the displayed state from it rather than the
289+
// mount-only `pressed`.
290+
const displayPressed = testOnly_pressed ?? pressed;
291+
287292
const resolvedStyle =
288-
typeof style === 'function' ? style({ pressed }) : style;
293+
typeof style === 'function' ? style({ pressed: displayPressed }) : style;
289294

290295
const resolvedChildren =
291-
typeof children === 'function' ? children({ pressed }) : children;
296+
typeof children === 'function'
297+
? children({ pressed: displayPressed })
298+
: children;
292299

293300
return (
294301
<Touchable

0 commit comments

Comments
 (0)