I am building bottom tabs navigator from react navigation v6 in react native mobile app but encountered an error.
ERROR TypeError: undefined is not a function
This error is located at:
in MaybeScreenContainer (created by BottomTabView)
in RNCSafeAreaProvider (created by SafeAreaProvider)
in SafeAreaProvider (created by SafeAreaInsetsContext)
in SafeAreaProviderCompat (created by BottomTabView)
in BottomTabView (created by BottomTabNavigator)
in PreventRemoveProvider (created by NavigationContent)
in NavigationContent
in Unknown (created by BottomTabNavigator)
in BottomTabNavigator (created by tabNavigation)
in EnsureSingleNavigator
in BaseNavigationContainer
in ThemeProvider
in NavigationContainerInner (created by tabNavigation)
in tabNavigation (created by App)
in RCTView (created by View)
in View (created by App)
in authState (created by App)
in App
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in KFC(RootComponent), js engine: hermes
The Code Of Tab Navigator That I have written for tabs. I am using physical device for test:
import React from 'react';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import Home from '../views/Home';
import Auth from '../views/Auth';
import Bucket from '../views/Bucket';
import Menu from '../views/Menu';
import {NavigationContainer} from '@react-navigation/native';
const Tab = createBottomTabNavigator();
export default function tabNavigation() {
return (
<NavigationContainer>
<Tab.Navigator initialRouteName="home">
<Tab.Screen name="home" component={Home} />
<Tab.Screen name="auth" component={Auth} />
<Tab.Screen name="bucket" component={Bucket} />
<Tab.Screen name="menu" component={Menu} />
</Tab.Navigator>
</NavigationContainer>
);
}
2
Answers
Try to replace your screen one by one and you will find your trouble maker
Ran into the same error. Turns out, bottom tabs navigator also needs react-native-screens.
yarn add react-native-screens
|npm install react-native-screens
should do the trick. You may have to re-build or clear your cache as well.