diff --git a/src/native-stack/navigators/createNativeStackNavigator.tsx b/src/native-stack/navigators/createNativeStackNavigator.tsx index 4653f00dc2..ea106c0ee0 100644 --- a/src/native-stack/navigators/createNativeStackNavigator.tsx +++ b/src/native-stack/navigators/createNativeStackNavigator.tsx @@ -35,6 +35,17 @@ function NativeStackNavigator({ screenOptions, }); + // Starting from React Navigation v6, `native-stack` should be imported from + // `@react-navigation/native-stack` rather than `react-native-screens/native-stack` + React.useEffect(() => { + // @ts-ignore navigation.dangerouslyGetParent was removed in v6 + if (navigation?.dangerouslyGetParent === undefined) { + console.warn( + 'Looks like you are importing `native-stack` from `react-native-screens/native-stack`. Since version 6 of `react-navigation`, it should be imported from `@react-navigation/native-stack`.' + ); + } + }, [navigation]); + React.useEffect( () => navigation?.addListener?.('tabPress', (e) => {