You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple tab bar on the bottom of the screen that lets you switch between different routes. Routes are lazily initialized -- their screen components are not mounted until they are first focused.
8
8
9
-
To use this navigator, you need to install [`@react-navigation/bottom-tabs`](https://github.com/react-navigation/navigation-ex/tree/master/packages/bottom-tabs):
9
+
To use this navigator, ensure that you have [react-navigation and its dependencies installed](getting-started.md), then install [`@react-navigation/bottom-tabs`](https://github.com/react-navigation/navigation-ex/tree/master/packages/bottom-tabs):
Component that renders a navigation drawer which can be opened and closed via gestures.
8
8
9
-
To use this navigator, you need to install [`@react-navigation/drawer`](https://github.com/react-navigation/navigation-ex/tree/master/packages/drawer):
9
+
To use this navigator, ensure that you have [react-navigation and its dependencies installed](getting-started.md), then install [`@react-navigation/drawer`](https://github.com/react-navigation/navigation-ex/tree/master/packages/drawer):
Now we need to install [`react-native-gesture-handler`](https://github.com/software-mansion/react-native-gesture-handler), [`react-native-reanimated`](https://github.com/software-mansion/react-native-reanimated), [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context).
16
-
17
-
If you are using Expo, to ensure that you get the compatible versions of the libraries, run:
Copy file name to clipboardExpand all lines: docs/getting-started.md
+82-6Lines changed: 82 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,6 @@ title: Getting started
4
4
sidebar_label: Getting started
5
5
---
6
6
7
-
React Navigation is born from the React Native community's need for an extensible yet easy-to-use navigation solution written entirely in JavaScript (so you can read and understand all of the source), on top of powerful native primitives.
8
-
9
-
Before you commit to using React Navigation for your project, you might want to read the [anti-pitch](pitch.md)— it will help you to understand the tradeoffs that we have chosen along with the areas where we consider the library to be deficient currently.
10
-
11
7
## What to expect
12
8
13
9
If you're already familiar with React Native then you'll be able to get moving with React Navigation quickly! If not, you may want to read sections 1 to 4 (inclusive) of [React Native Express](http://reactnativeexpress.com/) first, then come back here when you're done.
@@ -16,7 +12,7 @@ What follows within the _Fundamentals_ section of this documentation is a tour o
16
12
17
13
## Installation
18
14
19
-
Install the required packages in your React Native project.
15
+
Install the required packages in your React Native project:
20
16
21
17
```bash
22
18
yarn add @react-navigation/native@next
@@ -28,7 +24,83 @@ Or with npm
28
24
npm install @react-navigation/native@next
29
25
```
30
26
31
-
> When you use a navigator (such as stack navigator), you'll need to follow the installation instructions of that navigator for any additional configuration.
27
+
React Navigation is made up of some core utilities and those are then used by navigators to create the navigation structure in your app. Don't worry too much about this for now, it'll become clear soon enough! To frontload the installation work, let's also install and configure dependencies used by most navigators, then we can move forward with starting to write some code.
28
+
29
+
The libraries we will install now are [`react-native-gesture-handler`](https://github.com/software-mansion/react-native-gesture-handler), [`react-native-reanimated`](https://github.com/software-mansion/react-native-reanimated), [`react-native-screens`](https://github.com/kmagiera/react-native-screens) and [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context). If you already have these libraries installed and at the latest version, you are done here! Otherwise, read on.
30
+
31
+
#### Installing dependencies into an Expo managed project
> Note: You might get warnings related to peer dependencies after installation. They are usually caused my incorrect version ranges specified in some packages. You can safely ignore most warnings as long as your app builds.
52
+
53
+
From React Native 0.60 and higher, [linking is automatic](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md). So you **don't need to run**`react-native link`.
54
+
55
+
To complete the linking on iOS, make sure you have [Cocoapods](https://cocoapods.org/) installed. Then run:
56
+
57
+
```sh
58
+
cd ios
59
+
pod install
60
+
cd ..
61
+
```
62
+
63
+
To finalize installation of `react-native-screens` for Android, add the following two lines to `dependencies` section in `android/app/build.gradle`:
+ return new ReactActivityDelegate(this, getMainComponentName()) {
90
+
+ @Override
91
+
+ protected ReactRootView createRootView() {
92
+
+ return new RNGestureHandlerEnabledRootView(MainActivity.this);
93
+
+ }
94
+
+ };
95
+
+ }
96
+
}
97
+
```
98
+
99
+
Then add the following at the **top** (make sure it's at the top and there's nothing else before it) of your entry file, such as `index.js` or `App.js`:
100
+
101
+
```js
102
+
import'react-native-gesture-handler';
103
+
```
32
104
33
105
Now, we need to wrap the whole app in `NavigationNativeContainer`. Usually you'd do this in your entry file, such as `index.js` or `App.js`:
34
106
@@ -45,4 +117,8 @@ export default function App() {
45
117
}
46
118
```
47
119
120
+
> Note: When you use a navigator (such as stack navigator), you'll need to follow the installation instructions of that navigator for any additional dependencies. If you're getting an error "Unable to resolve module", you need to install that module in your project.
121
+
122
+
Now you are ready to build and run your app on the device/simulator.
123
+
48
124
Continue to ["Hello React Navigation"](hello-react-navigation.md) to start writing some code.
Copy file name to clipboardExpand all lines: docs/material-bottom-tab-navigator.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,10 @@ A material-design themed tab bar on the bottom of the screen that lets you switc
10
10
11
11
This wraps the [`BottomNavigation`](https://callstack.github.io/react-native-paper/bottom-navigation.html) component from [`react-native-paper`](https://reactnativepaper.com). If you [configure the Babel plugin](https://callstack.github.io/react-native-paper/getting-started.html), it won't include the whole `react-native-paper` library in your bundle.
12
12
13
-
To use this navigator, you need to install [`@react-navigation/material-bottom-tabs`](https://github.com/react-navigation/navigation-ex/tree/master/packages/material-bottom-tabs):
13
+
To use this navigator, ensure that you have [react-navigation and its dependencies installed](getting-started.md), then install [`@react-navigation/material-bottom-tabs`](https://github.com/react-navigation/navigation-ex/tree/master/packages/material-bottom-tabs):
This API also requires that you install `react-native-vector-icons`! If you are using Expo, it will just work out of the box. Otherwise, [follow these installation instructions](https://github.com/oblador/react-native-vector-icons#installation).
Copy file name to clipboardExpand all lines: docs/material-top-tab-navigator.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,10 @@ A material-design themed tab bar on the top of the screen that lets you switch b
8
8
9
9
This wraps [`react-native-tab-view`](https://github.com/react-native-community/react-native-tab-view).
10
10
11
-
To use this navigator, you need to install [`@react-navigation/material-top-tabs`](https://github.com/react-navigation/navigation-ex/tree/master/packages/material-top-tabs):
11
+
To use this navigator, ensure that you have [react-navigation and its dependencies installed](getting-started.md), then install [`@react-navigation/material-top-tabs`](https://github.com/react-navigation/navigation-ex/tree/master/packages/material-top-tabs):
Now we need to install [`react-native-gesture-handler`](https://github.com/software-mansion/react-native-gesture-handler) and [`react-native-reanimated`](https://github.com/software-mansion/react-native-reanimated).
Copy file name to clipboardExpand all lines: docs/native-stack-navigator.md
+2-33Lines changed: 2 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -10,39 +10,10 @@ By default the stack navigator is configured to have the familiar iOS and Androi
10
10
11
11
This uses native primitives (`UINavigationController` on iOS and `Fragment` on Android) for navigation using [`react-native-screens`](https://github.com/kmagiera/react-native-screens) under the hood, as opposed to the JS based stack navigator. While this provides native feeling and performance, it's not as customizable.
12
12
13
-
To use this navigator, you need to install [`@react-navigation/native-stack`](https://github.com/react-navigation/navigation-ex/tree/master/packages/native-stack):
13
+
To use this navigator, ensure that you have [react-navigation and its dependencies installed](getting-started.md), then install [`@react-navigation/native-stack`](https://github.com/react-navigation/navigation-ex/tree/master/packages/native-stack):
Make sure to enable `react-native-screens`. This needs to be done before our app renders. To do it, add the following code in your entry file (e.g. `App.js`):
@@ -53,8 +24,6 @@ import { enableScreens } from 'react-native-screens';
53
24
enableScreens();
54
25
```
55
26
56
-
Finally, run `react-native run-android` or `react-native run-ios` to launch the app on your device/simulator.
57
-
58
27
## API Definition
59
28
60
29
To use this navigator, import it from `@react-navigation/native-stack`:
Copy file name to clipboardExpand all lines: docs/stack-navigator.md
+2-70Lines changed: 2 additions & 70 deletions
Original file line number
Diff line number
Diff line change
@@ -8,80 +8,12 @@ Provides a way for your app to transition between screens where each new screen
8
8
9
9
By default the stack navigator is configured to have the familiar iOS and Android look & feel: new screens slide in from the right on iOS, fade in from the bottom on Android. On iOS the stack navigator can also be configured to a modal style where screens slide in from the bottom.
10
10
11
-
To use this navigator, you need to install [`@react-navigation/stack`](https://github.com/react-navigation/navigation-ex/tree/master/packages/stack):
11
+
To use this navigator, ensure that you have [react-navigation and its dependencies installed](getting-started.md), then install [`@react-navigation/stack`](https://github.com/react-navigation/navigation-ex/tree/master/packages/stack):
Now we need to install [`react-native-gesture-handler`](https://github.com/software-mansion/react-native-gesture-handler), [`react-native-screens`](https://github.com/kmagiera/react-native-screens) and [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context).
18
-
19
-
If you are using Expo, to ensure that you get the compatible versions of the libraries, run:
0 commit comments