Skip to content

Commit 831c711

Browse files
authored
Depracate old components (#4006)
## Description This PR: - Adds "Legacy" prefix to `Text` component - Marks `Text` and `Pressable` as deprecated - Removes export of old detector ## Test plan Tested that imported components are marked as deprecated.
1 parent 13c05f2 commit 831c711

4 files changed

Lines changed: 21 additions & 12 deletions

File tree

apps/common-app/src/legacy/release_tests/nestedText/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState } from 'react';
22
import { StyleSheet } from 'react-native';
33
import {
4-
Text,
4+
LegacyText,
55
GestureHandlerRootView,
66
TouchableOpacity,
77
} from 'react-native-gesture-handler';
@@ -11,29 +11,29 @@ export default function NestedText() {
1111

1212
return (
1313
<GestureHandlerRootView style={styles.container}>
14-
<Text style={{ fontSize: 30 }}>{`Counter: ${counter}`}</Text>
14+
<LegacyText style={{ fontSize: 30 }}>{`Counter: ${counter}`}</LegacyText>
1515

1616
<TouchableOpacity
1717
onPress={() => {
1818
console.log('Touchable');
1919
setCounter((prev) => prev + 1);
2020
}}>
21-
<Text
21+
<LegacyText
2222
style={[styles.textCommon, styles.outerText]}
2323
onPress={() => {
2424
console.log('Outer text');
2525
setCounter((prev) => prev + 1);
2626
}}>
2727
{'Outer Text '}
28-
<Text
28+
<LegacyText
2929
style={[styles.textCommon, styles.innerText]}
3030
onPress={() => {
3131
console.log('Nested text');
3232
setCounter((prev) => prev + 1);
3333
}}>
3434
{'Nested Text'}
35-
</Text>
36-
</Text>
35+
</LegacyText>
36+
</LegacyText>
3737
</TouchableOpacity>
3838
</GestureHandlerRootView>
3939
);

packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ import { PressableStateMachine } from './StateMachine';
4040
const DEFAULT_LONG_PRESS_DURATION = 500;
4141
const IS_TEST_ENV = isTestEnv();
4242

43-
const Pressable = (props: LegacyPressableProps) => {
43+
/**
44+
* @deprecated `LegacyPressable` is deprecated, use `Pressable` instead.
45+
*/
46+
const LegacyPressable = (props: LegacyPressableProps) => {
4447
const {
4548
testOnly_pressed,
4649
hitSlop,
@@ -390,4 +393,4 @@ const Pressable = (props: LegacyPressableProps) => {
390393
);
391394
};
392395

393-
export default Pressable;
396+
export default LegacyPressable;

packages/react-native-gesture-handler/src/components/Text.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import {
1414
import { GestureObjects as Gesture } from '../handlers/gestures/gestureObjects';
1515
import { GestureDetector } from '../handlers/gestures/GestureDetector';
1616

17-
export const Text = forwardRef(
17+
/**
18+
* @deprecated `LegacyText` is deprecated. Since Gesture Handler 3 you can wrap `Text` with `GestureDetector`.
19+
*/
20+
export const LegacyText = forwardRef(
1821
(
1922
props: RNTextProps,
2023
ref: ForwardedRef<React.ComponentRef<typeof RNText>>
@@ -73,5 +76,9 @@ export const Text = forwardRef(
7376
);
7477
}
7578
);
79+
80+
/**
81+
* @deprecated `LegacyText` is deprecated. Since Gesture Handler 3 you can wrap `Text` with `GestureDetector`.
82+
*/
7683
// eslint-disable-next-line @typescript-eslint/no-redeclare
77-
export type Text = typeof Text & RNText;
84+
export type LegacyText = typeof LegacyText & RNText;

packages/react-native-gesture-handler/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export { RotationGestureHandler } from './handlers/RotationGestureHandler';
5454
export { FlingGestureHandler } from './handlers/FlingGestureHandler';
5555
export { default as legacy_createNativeWrapper } from './handlers/createNativeWrapper';
5656
export type { NativeViewGestureHandlerProps } from './handlers/NativeViewGestureHandler';
57-
export { GestureDetector as LegacyGestureDetector } from './handlers/gestures/GestureDetector';
5857
export { GestureObjects as Gesture } from './handlers/gestures/gestureObjects';
5958
export type { TapGestureType as LegacyTapGesture } from './handlers/gestures/tapGesture';
6059
export type { PanGestureType as LegacyPanGesture } from './handlers/gestures/panGesture';
@@ -107,7 +106,7 @@ export {
107106
LegacyRefreshControl,
108107
} from './components/GestureComponents';
109108

110-
export { Text } from './components/Text';
109+
export { LegacyText } from './components/Text';
111110
export { HoverEffect } from './handlers/gestures/hoverGesture';
112111
export type {
113112
// Events

0 commit comments

Comments
 (0)