navigation: the navigation prop is passed in to every screen component (definition) in the native stack navigator (more about this later in "The navigation prop in depth").
stack navigator 會把 props : navigation 傳入每個 screen component
navigate('Details') - we call the navigate function (on the navigation prop — naming is hard!) with the name of the route that we'd like to move the user to.
在 navigation 裡的 navigate function 帶入特定 route
call navigation.navigate with a defined route name
navigation.navigate() V.S navigation.push()
Passing parameters to routes
用 route 去接 parameters route.params
API Reference
Navigation prop
Each screen component in your app is provided with the navigation propautomatically.
Fundamentals
moving between screens
Let's break this down:
navigation
: the navigation prop is passed in to every screen component (definition) in the native stack navigator (more about this later in "The navigation prop in depth"). stack navigator 會把 props : navigation 傳入每個 screen componentPassing parameters to routes
用 route 去接 parameters
route.params
API Reference
Navigation prop
Each screen component in your app is provided with the navigation prop
automatically
.stack navigator
: replace, push, pop, popToToptab navigator
: jumpTodrawer navigator
: jumpTo, openDrawer, closeDrawer, toggleDrawerNavigators
Native Stack Navigator
Hooks
useNavigation
如果 component 拿不到
navigation
object 可以使用 useNavigationuseRoute
useRoute is a hook which gives access to route object.