0

I want 4 screens inside the tab navigator and only the login and sign up screen inside the stack navigator with my home tabs therefore I am trying to use nested navigators, I have nested tab navigators inside the stack navigator, however when I run the software, the screen is showing up white as below:

enter image description here

The exact code that I have written is as follows:

import React from 'react';
import 'react-native-gesture-handler';
import {StatusBar} from 'react-native';
import {NavigationContainer, DarkTheme} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
import {createMaterialBottomTabNavigator} from '@react-navigation/material-bottom-tabs';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialIcons';

import Home from '../screens/Home';
import Search from '../screens/Search';
import Library from '../screens/Library';
import ProfileAuthor from '../screens/ProffileAuthor';
import Shoot from '../screens/Shoot';
import LoginScreen from '../screens/LoginScreen';
import SignUp from '../screens/SignUp';

const Stack = createStackNavigator();
const Tab = createMaterialBottomTabNavigator();

function myTabs() {
  return (
    <Tab.Navigator
      initialRouteName="Home"
      activeColor="#000"
      inactiveColor="#000"
      barStyle={{
        backgroundColor: '#FFF',
      }}>
      <Tab.Screen
        name="Home"
        component={Home}
        options={{
          title: 'Home',
          tabBarLabel: 'Home',
          tabBarIcon: ({color}) => (
            <MaterialCommunityIcons color={color} name="home" size={26} />
          ),
        }}
      />
      <Tab.Screen
        name="Search"
        component={Search}
        options={{
          title: 'Search',
          tabBarLabel: 'Search',
          tabBarIcon: ({color}) => (
            <MaterialCommunityIcons color={color} name="search" size={26} />
          ),
        }}
      />
      <Tab.Screen
        name="Upload"
        component={Shoot}
        options={{
          title: 'Upload',
          tabBarLabel: 'Upload',
          tabBarIcon: ({color}) => (
            <MaterialCommunityIcons color={color} name="add-box" size={26} />
          ),
        }}
      />
      <Tab.Screen
        name="Library"
        component={Library}
        options={{
          title: 'Library',
          tabBarLabel: 'Library',
          tabBarIcon: ({color}) => (
            <MaterialCommunityIcons
              color={color}
              name="person-outline"
              size={26}
            />
          ),
        }}
      />
    </Tab.Navigator>
  );
}

const Routes = () => {
  return (
  
      <NavigationContainer theme={DarkTheme}>
        <Stack.Screen
          name="login"
          component={LoginScreen}
          options={{
            header: () => null,
          }}
        />
        <Stack.Screen
          name="signup"
          component={SignUp}
          options={{
            header: () => null,
          }}
        />
        <Stack.Screen
          name="Home"
          component={myTabs}
          options={{
            header: () => null,
          }}
        />
        <Stack.Screen
          name="Video"
          component={ProfileAuthor}
          options={{
            header: () => null,
          }}
        />
      </NavigationContainer>
   
  );
};


export default Routes;

could anyone please tell me where am going wrong? any help would be great, thank you.

Ailurophile
  • 2,552
  • 7
  • 21
  • 46
TRINA CHAUDHURI
  • 627
  • 1
  • 11
  • 42

1 Answers1

0

I had missed out adding <Stack.Navigator> a very silly mistake but that resolved.

so inside Routes the code should be

const Routes = () => {
  return (
    <NavigationContainer theme={DarkTheme}>
      <Stack.Navigator>
        <Stack.Screen
          name="login"
          component={LoginScreen}
          options={{
            header: () => null,
          }}
        />
        <Stack.Screen
          name="signup"
          component={SignUp}
          options={{
            header: () => null,
          }}
        />
        <Stack.Screen
          name="Home"
          component={myTabs}
          options={{
            header: () => null,
          }}
        />
        <Stack.Screen
          name="Video"
          component={ProfileAuthor}
          options={{
            header: () => null,
          }}
        />
      </Stack.Navigator>
    </NavigationContainer>
  );
};
TRINA CHAUDHURI
  • 627
  • 1
  • 11
  • 42