@@ -78,9 +78,11 @@ export default function App() {
7878import * as React from ' react' ;
7979import { Button , View } from ' react-native' ;
8080import { createDrawerNavigator } from ' @react-navigation/drawer' ;
81- import { NavigationContainer } from ' @react-navigation/native' ;
81+ import { NavigationContainer , useNavigation } from ' @react-navigation/native' ;
82+
83+ function HomeScreen () {
84+ const navigation = useNavigation ();
8285
83- function HomeScreen ({ navigation }) {
8486 return (
8587 < View style= {{ flex: 1 , alignItems: ' center' , justifyContent: ' center' }}>
8688 < Button
@@ -91,7 +93,9 @@ function HomeScreen({ navigation }) {
9193 );
9294}
9395
94- function NotificationsScreen ({ navigation }) {
96+ function NotificationsScreen () {
97+ const navigation = useNavigation ();
98+
9599 return (
96100 < View style= {{ flex: 1 , alignItems: ' center' , justifyContent: ' center' }}>
97101 < Button onPress= {() => navigation .goBack ()} title= " Go back home" / >
@@ -203,15 +207,17 @@ export default function App() {
203207``` js name="Drawer open and close" snack version=7
204208import * as React from ' react' ;
205209import { View , Text , Button } from ' react-native' ;
206- import { NavigationContainer } from ' @react-navigation/native' ;
210+ import { NavigationContainer , useNavigation } from ' @react-navigation/native' ;
207211import {
208212 createDrawerNavigator ,
209213 DrawerContentScrollView ,
210214 DrawerItemList ,
211215 DrawerItem ,
212216} from ' @react-navigation/drawer' ;
213217
214- function Feed ({ navigation }) {
218+ function Feed () {
219+ const navigation = useNavigation ();
220+
215221 return (
216222 < View style= {{ flex: 1 , justifyContent: ' center' , alignItems: ' center' }}>
217223 < Text > Feed Screen< / Text >
@@ -359,15 +365,17 @@ export default function App() {
359365``` js name="Drawer toggle" snack version=7
360366import * as React from ' react' ;
361367import { View , Text , Button } from ' react-native' ;
362- import { NavigationContainer } from ' @react-navigation/native' ;
368+ import { NavigationContainer , useNavigation } from ' @react-navigation/native' ;
363369import {
364370 createDrawerNavigator ,
365371 DrawerContentScrollView ,
366372 DrawerItemList ,
367373 DrawerItem ,
368374} from ' @react-navigation/drawer' ;
369375
370- function Feed ({ navigation }) {
376+ function Feed () {
377+ const navigation = useNavigation ();
378+
371379 return (
372380 < View style= {{ flex: 1 , justifyContent: ' center' , alignItems: ' center' }}>
373381 < Text > Feed Screen< / Text >
@@ -522,15 +530,17 @@ export default function App() {
522530``` js name="Navigation dispatcher" snack version=7
523531import * as React from ' react' ;
524532import { View , Text , Button } from ' react-native' ;
525- import { NavigationContainer , DrawerActions } from ' @react-navigation/native' ;
533+ import { NavigationContainer , useNavigation , DrawerActions } from ' @react-navigation/native' ;
526534import {
527535 createDrawerNavigator ,
528536 DrawerContentScrollView ,
529537 DrawerItemList ,
530538 DrawerItem ,
531539} from ' @react-navigation/drawer' ;
532540
533- function Feed ({ navigation }) {
541+ function Feed () {
542+ const navigation = useNavigation ();
543+
534544 return (
535545 < View style= {{ flex: 1 , justifyContent: ' center' , alignItems: ' center' }}>
536546 < Text > Feed Screen< / Text >
0 commit comments