diff --git a/src/index.native.tsx b/src/index.native.tsx index 16c308caf3..c08bed8e32 100644 --- a/src/index.native.tsx +++ b/src/index.native.tsx @@ -1,11 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ -import React, { - Fragment, - PropsWithChildren, - ReactNode, - useEffect, - useRef, -} from 'react'; +import React, { PropsWithChildren, ReactNode, useEffect, useRef } from 'react'; import { Animated, Image, @@ -581,7 +575,9 @@ export type { const ScreenContext = React.createContext(InnerScreen); // context to be used when the user wants full screen swipe (see `gesture-handler` folder in repo) -const GHContext = React.createContext(Fragment); +const GHContext = React.createContext( + (props: { children: React.ReactNode }) => <>{props.children} +); class Screen extends React.Component { static contextType = ScreenContext; diff --git a/src/native-stack/views/NativeStackView.tsx b/src/native-stack/views/NativeStackView.tsx index 3a4dc4fced..6d3e82f818 100644 --- a/src/native-stack/views/NativeStackView.tsx +++ b/src/native-stack/views/NativeStackView.tsx @@ -419,7 +419,8 @@ function NativeStackViewInner({ const { key, routes } = state; const currentRouteKey = routes[state.index].key; - const topScreenOptions = descriptors[currentRouteKey].options; + const { goBackGesture, transitionAnimation, screenEdgeGesture } = + descriptors[currentRouteKey].options; const gestureDetectorBridge = React.useRef({ stackUseEffectCallback: _stackRef => { // this method will be override in GestureDetector @@ -432,12 +433,23 @@ function NativeStackViewInner({ const screensRefs = React.useRef({}); const ScreenGestureDetector = React.useContext(GHContext); + React.useEffect(() => { + if ( + ScreenGestureDetector.name !== 'GHWrapper' && + goBackGesture !== undefined + ) { + console.warn( + 'Cannot detect GestureDetectorProvider in a screen that uses `goBackGesture`. Make sure your navigator is wrapped in GestureDetectorProvider.' + ); + } + }, [ScreenGestureDetector.name, goBackGesture]); + return (