diff --git a/packages/react-native-gesture-handler/src/RNRenderer.ts b/packages/react-native-gesture-handler/src/RNRenderer.ts deleted file mode 100644 index 7a585b64c0..0000000000 --- a/packages/react-native-gesture-handler/src/RNRenderer.ts +++ /dev/null @@ -1,3 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-nocheck -export { default as RNRenderer } from 'react-native/Libraries/Renderer/shims/ReactNative'; diff --git a/packages/react-native-gesture-handler/src/RNRenderer.web.ts b/packages/react-native-gesture-handler/src/RNRenderer.web.ts deleted file mode 100644 index d46b825958..0000000000 --- a/packages/react-native-gesture-handler/src/RNRenderer.web.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const RNRenderer = { - findHostInstance_DEPRECATED: (_ref: any) => null, -}; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts index d15877fd5d..2b3857a4b5 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts @@ -10,7 +10,7 @@ import { dropHandlers } from './dropHandlers'; import { needsToReattach } from './needsToReattach'; import type { AttachedGestureState, GestureDetectorState } from './types'; import { updateHandlers } from './updateHandlers'; -import { useForceRender, validateDetectorChildren } from './utils'; +import { useForceRender } from './utils'; // Returns a function that's responsible for updating the attached gestures // If the view has changed, it will reattach the handlers to the new view @@ -34,7 +34,6 @@ export function useDetectorUpdater( didUnderlyingViewChange || needsToReattach(preparedGesture, gesturesToAttach) ) { - validateDetectorChildren(state.viewRef); dropHandlers(preparedGesture); attachHandlers({ preparedGesture, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts index cb13c24c9b..5b5f36c97f 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts @@ -1,7 +1,5 @@ import { useCallback, useRef, useState } from 'react'; -import { Platform } from 'react-native'; -import { RNRenderer } from '../../../RNRenderer'; import { isTestEnv, tagMessage } from '../../../utils'; import type { GestureHandlerNativeEvent, @@ -124,56 +122,6 @@ export function checkGestureCallbacksForWorklets(gesture: GestureType) { } } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export function validateDetectorChildren(ref: any) { - // Finds the first native view under the Wrap component and traverses the fiber tree upwards - // to check whether there is more than one native view as a pseudo-direct child of GestureDetector - // i.e. this is not ok: - // Wrap - // | - // / \ - // / \ - // / \ - // / \ - // NativeView NativeView - // - // but this is fine: - // Wrap - // | - // NativeView - // | - // / \ - // / \ - // / \ - // / \ - // NativeView NativeView - if (__DEV__ && Platform.OS !== 'web') { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const wrapType = - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - ref._reactInternals.elementType; - - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - let instance = - RNRenderer.findHostInstance_DEPRECATED( - ref - )._internalFiberInstanceHandleDEV; - - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - while (instance && instance.elementType !== wrapType) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - if (instance.sibling) { - throw new Error( - '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 or .' - ); - } - - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access - instance = instance.return; - } - } -} - export function useForceRender() { const [renderState, setRenderState] = useState(false); const forceRender = useCallback(() => {