Skip to content

Commit f72524e

Browse files
committed
Revert "Export new createNativeWrapper (#3971)"
This reverts commit bdf353d.
1 parent 957eed3 commit f72524e

5 files changed

Lines changed: 4 additions & 180 deletions

File tree

packages/docs-gesture-handler/docs/components/create-native-wrapper.mdx

Lines changed: 0 additions & 154 deletions
This file was deleted.

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ id: upgrading-to-3
33
title: Upgrading to the new API introduced in Gesture Handler 3
44
---
55

6-
import CodeComparison from '@site/src/components/CodeComparison';
7-
86
## Migrating gestures
97

8+
9+
import CodeComparison from '@site/src/components/CodeComparison';
10+
1011
The most important change brought by the Gesture Handler 3 is the new hook API. Migration is pretty straightforward. Instead of calling builder methods, everything is passed as a configuration object.
1112

1213
<CodeComparison
@@ -280,14 +281,6 @@ Other components have also been internally rewritten using the new hook API but
280281

281282
</details>
282283

283-
### createNativeWrapper
284-
285-
`createNativeWrapper` has been rewritten using the new hook API and exported under the original name. The old implementation is still available as `legacy_createNativeWrapper`. It also accepts new optional parameter - `detectorType`, which allows you to specify the type of the [gesture detector](/docs/fundamentals/gesture-detectors) that will be used internally. By default it uses `GestureDetector`.
286-
287-
While new `createNativeWrapper` should work out of the box, keep in mind that it wraps your component with `GestureDetector`, which in Gesture Handler 3 is a host component. This affects view hierarchy, so depending on your use case, you might want to use [`VirtualGestureDetector`](/docs/fundamentals/gesture-detectors#virtualgesturedetector) instead. To do that, simply pass the desired detector type as the second parameter of `createNativeWrapper`.
288-
289-
More on `createNativeWrapper` can be in the [dedicated section](/docs/components/create-native-wrapper) of the documentation.
290-
291284
## Replaced types
292285

293286
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 legacy_createNativeWrapper } from './handlers/createNativeWrapper';
55+
export { default as 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';

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,3 @@ export {
8383
export type { ComposedGesture } from './types';
8484

8585
export { GestureStateManager } from './gestureStateManager';
86-
87-
export { default as createNativeWrapper } from './createNativeWrapper';

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,13 @@ 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-
3938
- `onStart` -> `onActivate`
4039
- `onEnd` -> `onDeactivate`
4140
- `onTouchesCancelled` -> `onTouchesCancel`
4241

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

4544
All callbacks of a gesture are now using the same type:
46-
4745
- `usePanGesture()` -> `PanGestureEvent`
4846
- `useTapGesture()` -> `TapGestureEvent`
4947
- `useLongPressGesture()` -> `LongPressGestureEvent`
@@ -55,7 +53,6 @@ All callbacks of a gesture are now using the same type:
5553
- `useManualGesture()` -> `ManualGestureEvent`
5654

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

7067
`GestureStateManager` provides methods for imperative state management:
71-
7268
- .begin(handlerTag: number)
7369
- .activate(handlerTag: number)
7470
- .deactivate(handlerTag: number) (.end() in the old API)
7571
- .fail(handlerTag: number)
7672

7773
`handlerTag` can be obtained in two ways:
78-
7974
1. From the gesture object returned by the hook (`gesture.handlerTag`)
8075
2. From the event inside callback (`event.handlerTag`)
8176

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

9085
All relations from the old API and their counterparts in the new one:
91-
9286
- `Gesture.Race()` -> `useCompetingGestures()`
9387
- `Gesture.Simultaneous()` -> `useSimultaneousGestures()`
9488
- `Gesture.Exclusive()` -> `useExclusiveGestures()`
9589

9690
#### Cross components relations properties
9791

9892
Properties used to define cross-components interactions were renamed:
99-
10093
- `.simultaneousWithExternalGesture` -> `simultaneousWith:`
10194
- `.requireExternalGestureToFail` -> `requireToFail:`
10295
- `.blocksExternalGesture` -> `block:`
@@ -171,12 +164,6 @@ The implementation of buttons has been updated, resolving most button-related is
171164

172165
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`.
173166

174-
`createNativeWrapper` has been rewritten using the new hook API and exported under the original name. The old implementation is still available as `legacy_createNativeWrapper`. It also accepts new optional parameter - `detectorType`, which allows you to specify the type of the gesture detector that will be used internally. By default it uses `GestureDetector`.
175-
176-
While new `createNativeWrapper` should work out of the box, keep in mind that it wraps your component with `GestureDetector`, which in Gesture Handler 3 is a host component. This affects view hierarchy, so depending on use case, you might want to use `VirtualGestureDetector` instead.
177-
178-
Before changing, ask user about their intention - if they prefer to keep legacy version, change it to `legacy_createNativeWrapper`. If not, keep `createNativeWrapper`, then notify user that in case of problems with view hierarchy they should wrap the relevant subtree with `InterceptingGestureDetector` and pass `GestureDetectorType.Virtual` as the `detectorType` argument in `createNativeWrapper`.
179-
180167
### Replaced types
181168

182169
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)