Skip to content

Commit 19b619b

Browse files
authored
Revert "Export new createNativeWrapper (#3971)" (#4001)
This reverts commit bdf353d. ## Description We decided that it will be better not to export new `createNativeWrapper` as it might be confusing when to use it. ## Test plan Try to import `createNativeWrapper` Read docs 🤓
1 parent cefb702 commit 19b619b

6 files changed

Lines changed: 10 additions & 170 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

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: 4 additions & 7 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
@@ -282,11 +283,7 @@ Other components have also been internally rewritten using the new hook API but
282283

283284
### createNativeWrapper
284285

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.
286+
`createNativeWrapper` is deprecated and it is now exported as `legacy_createNativeWrapper`.
290287

291288
## Replaced types
292289

packages/react-native-gesture-handler/src/handlers/createNativeWrapper.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const NATIVE_WRAPPER_PROPS_FILTER = [
2020
'onGestureHandlerStateChange',
2121
] as const;
2222

23+
/**
24+
* @deprecated `createNativeWrapper` is deprecated and will be removed in favor of using `GestureDetector` with `Native` gesture directly.
25+
*/
2326
export default function createNativeWrapper<P>(
2427
Component: React.ComponentType<P>,
2528
config: Readonly<NativeViewGestureHandlerProps> = {}

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: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,7 @@ The implementation of buttons has been updated, resolving most button-related is
171171

172172
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`.
173173

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`.
174+
Rename all instances of createNativeWrapper to legacy_createNativeWrapper. This includes both the import statements and the function calls.
179175

180176
### Replaced types
181177

0 commit comments

Comments
 (0)