Skip to content

Commit 8ba5e3a

Browse files
javachefacebook-github-bot
authored andcommitted
Fix refs in Pressable leading to tree clone (facebook#39324)
Summary: `useImperativeHandle` without a dependencies array causes React to re-clone the tree, leading to undesirable layout effects. Changelog: [Internal] Reviewed By: fabriziocucci Differential Revision: D49056493
1 parent c0244c6 commit 8ba5e3a

File tree

1 file changed

+2
-1
lines changed
  • packages/react-native/Libraries/Components/Pressable

1 file changed

+2
-1
lines changed

packages/react-native/Libraries/Components/Pressable/Pressable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type {
2424
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
2525
import usePressability from '../../Pressability/usePressability';
2626
import {type RectOrSize} from '../../StyleSheet/Rect';
27+
import useMergeRefs from '../../Utilities/useMergeRefs';
2728
import View from '../View/View';
2829
import useAndroidRippleForView, {
2930
type RippleConfig,
@@ -235,7 +236,7 @@ function Pressable(props: Props, forwardedRef): React.Node {
235236
} = props;
236237

237238
const viewRef = useRef<React.ElementRef<typeof View> | null>(null);
238-
useImperativeHandle(forwardedRef, () => viewRef.current);
239+
useMergeRefs(forwardedRef, viewRef);
239240

240241
const android_rippleConfig = useAndroidRippleForView(android_ripple, viewRef);
241242

0 commit comments

Comments
 (0)