When I navigate from signup screen to home screen I have got following error which is mentioned below. Where I have used the nested navigation in react native. This is my app.js
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import {createDrawerNavigator} from '@react-navigation/drawer';
import Profile from './src/components/Profile';
import SignUp from './src/components/SignUp';
import LoginScreen from './src/screens/LoginScreen'
import ViewAllBooks from './src/screens/ViewAllBooks'
import Home from './src/screens/Home'
const Stack = createStackNavigator();
// for drawer navigation
const Drawer = createDrawerNavigator();
function Root() {
return (
<Drawer.Navigator>
<Drawer.Screen name="Home" component={Home} />
</Drawer.Navigator>
);
}
function App() {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="signUp">
<Stack.Screen name="Home" component={Root} options={{ headerShown: false }}/>
<Stack.Screen name="signUp" component={SignUp} options={{ headerShown: false }} />
<Stack.Screen name="profile" component={Profile} options={{ headerShown: false }} />
<Stack.Screen name="loginScreen" component={LoginScreen} options={{ headerShown: false }} />
<Stack.Screen name="viewAllBooks" component={ViewAllBooks} options={{ headerShown: false }} />
</Stack.Navigator>
</NavigationContainer>
// <Navigator/>
);
}
export default App;
The error is Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `DrawerNavigator`.
This error is located at:
in DrawerNavigator (at App.js:20)
in Root (at SceneView.tsx:122)
in StaticContainer
in StaticContainer (at SceneView.tsx:115)
in EnsureSingleNavigator (at SceneView.tsx:114)
in SceneView (at useDescriptors.tsx:153)
in RCTView (at View.js:34)
in View (at CardContainer.tsx:245)