react-native-navigation.
React Navigation
The community solution to navigation is a standalone library that allows developers to set up the screens of an app with a few lines of code. React Navigation for Vega Platform can be found in React Navigation.Starter template
If you’re starting a new project, you can use the React Navigation template to quickly set up a new project with Expo:README.md for more information on how to get started.
Installation and setup
First, you need to install them in your project:-
If you have an Expo managed project, install the dependencies with
expo: -
If you have a bare React Native project, install the dependencies with
npm:For iOS with bare React Native project, make sure you have CocoaPods installed. Then install the pods to complete the installation:
Usage
Now you can create an app with a home screen and a profile screen:RootStack is a navigator with 2 screens (Home and Profile), defined in the screens property in createNativeStackNavigator. Similarly, you can define as many screens as you like.
You can specify options such as the screen title for each screen in the options property of each screen. Each screen definition also needs a screen property that is a React component or another navigator.
Inside each screen component, you can use the useNavigation hook to get the navigation object, which has various methods to link to other screens. For example, you can use navigation.navigate to go to the Profile screen:
native-stack navigator uses the native APIs: UINavigationController on iOS and Fragment on Android so that navigation built with createNativeStackNavigator will behave the same and have the similar performance characteristics as apps built natively on top of those APIs.
React Navigation also has packages for different kind of navigators such as tabs and drawer. You can use them to implement various patterns in your app.
For a complete intro to React Navigation, follow the React Navigation Getting Started Guide.
