How to use Stack Navigator Inside a Drawer Navigator in react native

I have a drawer with two components, Home screen and todoList. From todoList page I want to go to Add Item page. So when I nest my stack navigator and navigate to todolist page from drawer, When i click the + button in todolist it says “The action ‘NAVIGATE’ with payload {“name”:”AddNewItem”} was not handled by any navigator.Do you have a screen named ‘AddNewItem’?.”

I read the documentation but I am not able to resolve this issue pls help. Code and images are attached below

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import { NavigationContainer } from "@react-navigation/native";
import React from "react";
import { SafeAreaProvider } from "react-native-safe-area-context";
import 'react-native-gesture-handler';
import { createDrawerNavigator } from '@react-navigation/drawer';
import HomeScreen from "./src/pages/HomeScreen";
import TodoList from "./src/pages/TodoList";
import { Button } from "react-native-paper";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import AddNewItem from "./src/pages/AddNewItem";
function App() {
const Drawer = createDrawerNavigator()
const Stack = createNativeStackNavigator();
const MyStack=()=>{
return(
<Stack.Navigator initialRouteName="TodoList">
<Stack.Screen name="To do List" component={TodoList}></Stack.Screen>
<Stack.Screen name="Add new Item" component={AddNewItem}></Stack.Screen>
</Stack.Navigator>
)
}
return (
<NavigationContainer>
<SafeAreaProvider>
<Drawer.Navigator initialRouteName="Feed" backBehavior="history">
<Drawer.Screen name="Home" component={HomeScreen} options={{headerTitle:"My Home",headerRight:()=>(<Button mode="contained" style={{ margin: 8 }} onPress={() => console.log("hello")}>Login</Button>)}} />
<Drawer.Screen name="TodoList" component={MyStack} />
</Drawer.Navigator>
</SafeAreaProvider>
</NavigationContainer>
)
}
export default App;
</code>
<code>import { NavigationContainer } from "@react-navigation/native"; import React from "react"; import { SafeAreaProvider } from "react-native-safe-area-context"; import 'react-native-gesture-handler'; import { createDrawerNavigator } from '@react-navigation/drawer'; import HomeScreen from "./src/pages/HomeScreen"; import TodoList from "./src/pages/TodoList"; import { Button } from "react-native-paper"; import { createNativeStackNavigator } from "@react-navigation/native-stack"; import AddNewItem from "./src/pages/AddNewItem"; function App() { const Drawer = createDrawerNavigator() const Stack = createNativeStackNavigator(); const MyStack=()=>{ return( <Stack.Navigator initialRouteName="TodoList"> <Stack.Screen name="To do List" component={TodoList}></Stack.Screen> <Stack.Screen name="Add new Item" component={AddNewItem}></Stack.Screen> </Stack.Navigator> ) } return ( <NavigationContainer> <SafeAreaProvider> <Drawer.Navigator initialRouteName="Feed" backBehavior="history"> <Drawer.Screen name="Home" component={HomeScreen} options={{headerTitle:"My Home",headerRight:()=>(<Button mode="contained" style={{ margin: 8 }} onPress={() => console.log("hello")}>Login</Button>)}} /> <Drawer.Screen name="TodoList" component={MyStack} /> </Drawer.Navigator> </SafeAreaProvider> </NavigationContainer> ) } export default App; </code>
import { NavigationContainer } from "@react-navigation/native";
import React from "react";
import { SafeAreaProvider } from "react-native-safe-area-context";
import 'react-native-gesture-handler';
import { createDrawerNavigator } from '@react-navigation/drawer';
import HomeScreen from "./src/pages/HomeScreen";
import TodoList from "./src/pages/TodoList";
import { Button } from "react-native-paper";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import AddNewItem from "./src/pages/AddNewItem";
function App() {

  const Drawer = createDrawerNavigator()

  const Stack = createNativeStackNavigator();
  const MyStack=()=>{
    return(
      <Stack.Navigator initialRouteName="TodoList">
          <Stack.Screen name="To do List" component={TodoList}></Stack.Screen>
          <Stack.Screen name="Add new Item" component={AddNewItem}></Stack.Screen>
      </Stack.Navigator>
    )
  }
  return (
    <NavigationContainer>
      <SafeAreaProvider>
        <Drawer.Navigator initialRouteName="Feed" backBehavior="history">
          <Drawer.Screen name="Home" component={HomeScreen} options={{headerTitle:"My Home",headerRight:()=>(<Button mode="contained" style={{ margin: 8 }} onPress={() => console.log("hello")}>Login</Button>)}} />
          <Drawer.Screen name="TodoList" component={MyStack} />
          
        </Drawer.Navigator>
      </SafeAreaProvider>
    </NavigationContainer>


  )
}
export default App;

Code of the App Component

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import { useState } from "react"
import { View, Text } from "react-native"
import { useAppSelector } from "../redux/Hooks/hooks"
import { FAB } from 'react-native-paper';
import { useNavigation } from "@react-navigation/native";
function TodoList() {
const [input, setInput] = useState('')
const pending = useAppSelector((state) => state.pending.value)
const navigation = useNavigation()
return (
<>
<View style={{ justifyContent: "center", margin: 10 }}>
<View>
<Text style={{ color: "black", fontSize: 20, alignItems: "center" }}>Pending Works</Text>
</View>
<FAB icon="plus" onPress={() => navigation.navigate("AddNewItem" as never)}></FAB>
</View>
</>
)
}
export default TodoList
</code>
<code>import { useState } from "react" import { View, Text } from "react-native" import { useAppSelector } from "../redux/Hooks/hooks" import { FAB } from 'react-native-paper'; import { useNavigation } from "@react-navigation/native"; function TodoList() { const [input, setInput] = useState('') const pending = useAppSelector((state) => state.pending.value) const navigation = useNavigation() return ( <> <View style={{ justifyContent: "center", margin: 10 }}> <View> <Text style={{ color: "black", fontSize: 20, alignItems: "center" }}>Pending Works</Text> </View> <FAB icon="plus" onPress={() => navigation.navigate("AddNewItem" as never)}></FAB> </View> </> ) } export default TodoList </code>
import { useState } from "react"
import { View, Text } from "react-native"
import { useAppSelector } from "../redux/Hooks/hooks"
import { FAB } from 'react-native-paper';
import { useNavigation } from "@react-navigation/native";
function TodoList() {
    const [input, setInput] = useState('')
    const pending = useAppSelector((state) => state.pending.value)
    const navigation = useNavigation()
    return (
        <>
            <View style={{ justifyContent: "center", margin: 10 }}>
                <View>
                    <Text style={{ color: "black", fontSize: 20, alignItems: "center" }}>Pending Works</Text>

                </View>
                <FAB icon="plus" onPress={() => navigation.navigate("AddNewItem" as never)}></FAB>
            </View>
        </>


    )
}
export default TodoList

code of todolist page
This is the drawer screen
This is the todolist page

I read the documentation of nested navigation but it did not work

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật