Skip to content

Commit 0417378

Browse files
authored
Fix RNRenderer import for React Native 0.86+ (#4160)
## Description React Native 0.86 removed `Libraries/Renderer/shims/ReactNative`, breaking the `RNRenderer` import. This PR switch to `RendererProxy` and fall back to the legacy shim for compatibility with RN < 0.86.
1 parent 8c3893a commit 0417378

4 files changed

Lines changed: 1 addition & 60 deletions

File tree

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

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

packages/react-native-gesture-handler/src/RNRenderer.web.ts

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

packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { dropHandlers } from './dropHandlers';
1010
import { needsToReattach } from './needsToReattach';
1111
import type { AttachedGestureState, GestureDetectorState } from './types';
1212
import { updateHandlers } from './updateHandlers';
13-
import { useForceRender, validateDetectorChildren } from './utils';
13+
import { useForceRender } from './utils';
1414

1515
// Returns a function that's responsible for updating the attached gestures
1616
// If the view has changed, it will reattach the handlers to the new view
@@ -34,7 +34,6 @@ export function useDetectorUpdater(
3434
didUnderlyingViewChange ||
3535
needsToReattach(preparedGesture, gesturesToAttach)
3636
) {
37-
validateDetectorChildren(state.viewRef);
3837
dropHandlers(preparedGesture);
3938
attachHandlers({
4039
preparedGesture,

packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { useCallback, useRef, useState } from 'react';
2-
import { Platform } from 'react-native';
32

4-
import { RNRenderer } from '../../../RNRenderer';
53
import { isTestEnv, tagMessage } from '../../../utils';
64
import type {
75
GestureHandlerNativeEvent,
@@ -124,56 +122,6 @@ export function checkGestureCallbacksForWorklets(gesture: GestureType) {
124122
}
125123
}
126124

127-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
128-
export function validateDetectorChildren(ref: any) {
129-
// Finds the first native view under the Wrap component and traverses the fiber tree upwards
130-
// to check whether there is more than one native view as a pseudo-direct child of GestureDetector
131-
// i.e. this is not ok:
132-
// Wrap
133-
// |
134-
// / \
135-
// / \
136-
// / \
137-
// / \
138-
// NativeView NativeView
139-
//
140-
// but this is fine:
141-
// Wrap
142-
// |
143-
// NativeView
144-
// |
145-
// / \
146-
// / \
147-
// / \
148-
// / \
149-
// NativeView NativeView
150-
if (__DEV__ && Platform.OS !== 'web') {
151-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
152-
const wrapType =
153-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
154-
ref._reactInternals.elementType;
155-
156-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
157-
let instance =
158-
RNRenderer.findHostInstance_DEPRECATED(
159-
ref
160-
)._internalFiberInstanceHandleDEV;
161-
162-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
163-
while (instance && instance.elementType !== wrapType) {
164-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
165-
if (instance.sibling) {
166-
throw new Error(
167-
'GestureDetector has more than one native view as its children. This can happen if you are using a custom component that renders multiple views, like React.Fragment. You should wrap content of GestureDetector with a <View> or <Animated.View>.'
168-
);
169-
}
170-
171-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
172-
instance = instance.return;
173-
}
174-
}
175-
}
176-
177125
export function useForceRender() {
178126
const [renderState, setRenderState] = useState(false);
179127
const forceRender = useCallback(() => {

0 commit comments

Comments
 (0)