Skip to content

Commit aa95b97

Browse files
committed
Export with legacy prefix
1 parent f72524e commit aa95b97

5 files changed

Lines changed: 18 additions & 5 deletions

File tree

apps/common-app/src/legacy/basic/pagerAndDrawer/index.android.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import ViewPagerAndroid from '@react-native-community/viewpager';
22
import React, { Component } from 'react';
33
import { StyleSheet, Text, View } from 'react-native';
44
import {
5-
createNativeWrapper,
5+
legacy_createNativeWrapper,
66
LegacyDrawerLayoutAndroid,
77
} from 'react-native-gesture-handler';
88

9-
const WrappedViewPagerAndroid = createNativeWrapper(ViewPagerAndroid, {
9+
const WrappedViewPagerAndroid = legacy_createNativeWrapper(ViewPagerAndroid, {
1010
disallowInterruption: true,
1111
});
1212

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
TapGestureHandler,
1717
TextInput,
1818
RectButton,
19-
createNativeWrapper,
19+
legacy_createNativeWrapper,
2020
TapGestureHandlerStateChangeEvent,
2121
} from 'react-native-gesture-handler';
2222
import Slider from '@react-native-community/slider';
@@ -30,7 +30,7 @@ import { PressBox } from '../../basic/multitap';
3030
import { LoremIpsum } from '../../../common';
3131
import { InfoButton } from './InfoButton';
3232

33-
const WrappedSlider = createNativeWrapper(Slider, {
33+
const WrappedSlider = legacy_createNativeWrapper(Slider, {
3434
shouldCancelWhenOutside: false,
3535
shouldActivateOnStart: true,
3636
disallowInterruption: true,

packages/docs-gesture-handler/docs/guides/upgrading-to-3.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ Other components have also been internally rewritten using the new hook API but
281281

282282
</details>
283283

284+
### createNativeWrapper
285+
286+
`createNativeWrapper` is now exported as `legacy_createNativeWrapper`.
287+
284288
## Replaced types
285289

286290
Most of the types, like `TapGesture`, are still present in Gesture Handler 3. However, they are now used in new hook API. Types for old API now have `Legacy` prefix, e.g. `TapGesture` becomes `LegacyTapGesture`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export { PanGestureHandler } from './handlers/PanGestureHandler';
5252
export { PinchGestureHandler } from './handlers/PinchGestureHandler';
5353
export { RotationGestureHandler } from './handlers/RotationGestureHandler';
5454
export { FlingGestureHandler } from './handlers/FlingGestureHandler';
55-
export { default as createNativeWrapper } from './handlers/createNativeWrapper';
55+
export { default as legacy_createNativeWrapper } from './handlers/createNativeWrapper';
5656
export type { NativeViewGestureHandlerProps } from './handlers/NativeViewGestureHandler';
5757
export { GestureDetector as LegacyGestureDetector } from './handlers/gestures/GestureDetector';
5858
export { GestureObjects as Gesture } from './handlers/gestures/gestureObjects';

skills/gesture-handler-3-migration/SKILL.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ The exception to thait is `Gesture.ForceTouch` which DOES NOT have a counterpart
3535
#### Callback changes
3636

3737
In Gesture Handler 3 some of the callbacks were renamed, namely:
38+
3839
- `onStart` -> `onActivate`
3940
- `onEnd` -> `onDeactivate`
4041
- `onTouchesCancelled` -> `onTouchesCancel`
4142

4243
In the hooks API `onChange` is no longer available. Instead the `*change*` properties were moved to the event available inside `onUpdate`.
4344

4445
All callbacks of a gesture are now using the same type:
46+
4547
- `usePanGesture()` -> `PanGestureEvent`
4648
- `useTapGesture()` -> `TapGestureEvent`
4749
- `useLongPressGesture()` -> `LongPressGestureEvent`
@@ -53,6 +55,7 @@ All callbacks of a gesture are now using the same type:
5355
- `useManualGesture()` -> `ManualGestureEvent`
5456

5557
The exception to this is touch events:
58+
5659
- `onTouchesDown`
5760
- `onTouchesUp`
5861
- `onTouchesMove`
@@ -65,12 +68,14 @@ Where each callback receives `GestureTouchEvent` regardless of the hook used.
6568
In Gesture Handler 3, `stateManager` is no longer passed to `TouchEvent` callbacks. Instead, you should use the global `GestureStateManager`.
6669

6770
`GestureStateManager` provides methods for imperative state management:
71+
6872
- .begin(handlerTag: number)
6973
- .activate(handlerTag: number)
7074
- .deactivate(handlerTag: number) (.end() in the old API)
7175
- .fail(handlerTag: number)
7276

7377
`handlerTag` can be obtained in two ways:
78+
7479
1. From the gesture object returned by the hook (`gesture.handlerTag`)
7580
2. From the event inside callback (`event.handlerTag`)
7681

@@ -83,13 +88,15 @@ Callback definitions CANNOT reference the gesture that's being defined. In this
8388
`Gesture.Simultaneous(gesture1, gesture2);` becomes `useSimultaneousGestures(pan1, pan2);`
8489

8590
All relations from the old API and their counterparts in the new one:
91+
8692
- `Gesture.Race()` -> `useCompetingGestures()`
8793
- `Gesture.Simultaneous()` -> `useSimultaneousGestures()`
8894
- `Gesture.Exclusive()` -> `useExclusiveGestures()`
8995

9096
#### Cross components relations properties
9197

9298
Properties used to define cross-components interactions were renamed:
99+
93100
- `.simultaneousWithExternalGesture` -> `simultaneousWith:`
94101
- `.requireExternalGestureToFail` -> `requireToFail:`
95102
- `.blocksExternalGesture` -> `block:`
@@ -164,6 +171,8 @@ The implementation of buttons has been updated, resolving most button-related is
164171

165172
Other components have also been internally rewritten using the new hook API but are exported under their original names, so no changes are necessary on your part. However, if you need to use the previous implementation for any reason, the legacy components are also available and are prefixed with `Legacy`, e.g., `ScrollView` is now available as `LegacyScrollView`.
166173

174+
Rename all instances of createNativeWrapper to legacy_createNativeWrapper. This includes both the import statements and the function calls.
175+
167176
### Replaced types
168177

169178
Most of the types used in the builder API, like `TapGesture`, are still present in Gesture Handler 3. However, they are now used in new hook API. Types for builder API now have `Legacy` prefix, e.g. `TapGesture` becomes `LegacyTapGesture`.

0 commit comments

Comments
 (0)