Commit c079c77
## Description
The `Pressable` was developed with an incorrect assumption that the
`onLayout` prop is not available on the `NativeButton`.
This PR defines the `onLayout` on `RawButtonProps`, and makes use of
said prop in `Pressable` to remove the need for the
`dimensionsAfterResize` property.
This PR also marks `dimensionsAfterResize` as deprecated.
Fixes #3600
## Test plan
1. Use the provided test code.
2. Notice how the `Pressable`, despite starting out with `0, 0`
dimensions, responds correctly to all press events.
3. Use the `Pressable` examples in our example app to confirm there are
no new issues with the component.
## Test code
<details>
```tsx
import React, { useEffect } from 'react';
import { StyleSheet } from 'react-native';
import {
Pressable,
GestureHandlerRootView,
} from 'react-native-gesture-handler';
import Animated, {
useSharedValue,
useAnimatedStyle,
withTiming,
} from 'react-native-reanimated';
export default function EmptyExample() {
const opacity = useSharedValue(0);
const containerAnimatedStyle = useAnimatedStyle(() => {
'worklet';
return {
opacity: opacity.value,
transform: [{ scale: opacity.value }],
};
});
useEffect(() => {
opacity.value = withTiming(1, { duration: 200 });
}, [opacity]);
return (
<GestureHandlerRootView style={styles.container}>
<Animated.View style={containerAnimatedStyle}>
<Pressable style={styles.box} onPress={() => console.log('press')} />
</Animated.View>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
gap: 10,
},
box: {
width: 150,
height: 150,
backgroundColor: 'red',
alignItems: 'center',
justifyContent: 'center',
},
});
```
</details>
---------
Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
1 parent 9f33d64 commit c079c77
File tree
3 files changed
+19
-27
lines changed- packages/react-native-gesture-handler/src/components
- Pressable
3 files changed
+19
-27
lines changedLines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
59 | 65 | | |
60 | 66 | | |
61 | 67 | | |
| |||
Lines changed: 11 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
49 | | - | |
50 | 48 | | |
51 | 49 | | |
52 | 50 | | |
| |||
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
| 61 | + | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
| |||
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
72 | | - | |
73 | 71 | | |
74 | 72 | | |
75 | 73 | | |
| |||
79 | 77 | | |
80 | 78 | | |
81 | 79 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | 80 | | |
86 | 81 | | |
87 | 82 | | |
| |||
109 | 104 | | |
110 | 105 | | |
111 | 106 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | 107 | | |
128 | 108 | | |
129 | 109 | | |
| |||
377 | 357 | | |
378 | 358 | | |
379 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
380 | 368 | | |
381 | 369 | | |
382 | 370 | | |
383 | 371 | | |
384 | | - | |
| 372 | + | |
385 | 373 | | |
386 | 374 | | |
387 | 375 | | |
| |||
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
172 | | - | |
173 | | - | |
| 171 | + | |
174 | 172 | | |
175 | 173 | | |
176 | 174 | | |
0 commit comments