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
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/MST-integration.md
+10-2
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,19 @@ title: Integrating with MobX State Tree
4
4
sidebar_label: MobX State Tree integration
5
5
---
6
6
7
-
> TODO: This guide is incomplete. Please help improve this by sending pull requests.
7
+
:::note
8
+
9
+
This guide is incomplete. Please help improve this by sending pull requests.
10
+
11
+
:::
8
12
9
13
This guide explores possible way to use React Navigation in a React Native project that uses [MobX State Tree](https://github.com/mobxjs/mobx-state-tree)(MST) for state management. The guide is accompanied by a [sample app](https://github.com/vonovak/react-navigation-mst-demo). Parts of the guide may be relevant also for users of [MobX](https://github.com/mobxjs/mobx) but please be aware of the fact that MobX does not come with a built-in solution for (de)serializing its state.
10
14
11
-
> Please note that in this guide, Mobx State Tree is not used to manage the navigation state itself - just the navigation params!
15
+
:::note
16
+
17
+
Please note that in this guide, Mobx State Tree is not used to manage the navigation state itself - just the navigation params!
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/auth-flow.md
+15-3
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,11 @@ Most apps require that a user authenticates in some way to have access to data a
11
11
- When the state has loaded, the user is presented with either authentication screens or the main app, depending on whether valid authentication state was loaded.
12
12
- When the user signs out, we clear the authentication state and send them back to authentication screens.
13
13
14
-
> Note: We say "authentication screens" because usually there is more than one. You may have a main screen with a username and password field, another for "forgot password", and another set for sign up.
14
+
:::note
15
+
16
+
We say "authentication screens" because usually there is more than one. You may have a main screen with a username and password field, another for "forgot password", and another set for sign up.
17
+
18
+
:::
15
19
16
20
## What we need
17
21
@@ -118,11 +122,19 @@ state.userToken == null ? (
118
122
);
119
123
```
120
124
121
-
> If you have both your login-related screens and rest of the screens in two different Stack navigators, we recommend to use a single Stack navigator and place the conditional inside instead of using 2 different navigators. This makes it possible to have a proper transition animation during login/logout.
125
+
:::tip
126
+
127
+
If you have both your login-related screens and rest of the screens in two different Stack navigators, we recommend to use a single Stack navigator and place the conditional inside instead of using 2 different navigators. This makes it possible to have a proper transition animation during login/logout.
128
+
129
+
:::
122
130
123
131
## Implement the logic for restoring the token
124
132
125
-
> Note: The following is just an example of how you might implement the logic for authentication in your app. You don't need to follow it as is.
133
+
:::note
134
+
135
+
The following is just an example of how you might implement the logic for authentication in your app. You don't need to follow it as is.
136
+
137
+
:::
126
138
127
139
From the previous snippet, we can see that we need 3 state variables:
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/configuring-links.md
+5-1
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,11 @@ function App() {
37
37
38
38
When you specify the `linking` prop, React Navigation will handle incoming links automatically. On Android and iOS, it'll use React Native's [`Linking` module](https://reactnative.dev/docs/linking) to handle incoming links, both when the app was opened with the link, and when new links are received when the app is open. On the Web, it'll use the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to sync the URL with the browser.
39
39
40
-
> Note: Currently there seems to be bug ([facebook/react-native#25675](https://github.com/facebook/react-native/issues/25675)) which results in it never resolving on Android. We add a timeout to avoid getting stuck forever, but it means that the link might not be handled in some cases.
40
+
:::warning
41
+
42
+
Currently there seems to be bug ([facebook/react-native#25675](https://github.com/facebook/react-native/issues/25675)) which results in it never resolving on Android. We add a timeout to avoid getting stuck forever, but it means that the link might not be handled in some cases.
43
+
44
+
:::
41
45
42
46
You can also pass a [`fallback`](navigation-container.md#fallback) prop to `NavigationContainer` which controls what's displayed when React Navigation is trying to resolve the initial deep link URL.
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/drawer-layout.md
+5-1
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,11 @@ Then, you need to install and configure the libraries that are required by the d
46
46
import'react-native-gesture-handler';
47
47
```
48
48
49
-
> Note: If you are building for Android or iOS, do not skip this step, or your app may crash in production even if it works fine in development. This is not applicable to other platforms.
49
+
:::warning
50
+
51
+
If you are building for Android or iOS, do not skip this step, or your app may crash in production even if it works fine in development. This is not applicable to other platforms.
52
+
53
+
:::
50
54
51
55
3. If you're on a Mac and developing for iOS, you also need to install the pods (via [Cocoapods](https://cocoapods.org/)) to complete the linking.
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/drawer-navigator.md
+10-2
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,11 @@ Then, you need to install and configure the libraries that are required by the d
46
46
import'react-native-gesture-handler';
47
47
```
48
48
49
-
> Note: If you are building for Android or iOS, do not skip this step, or your app may crash in production even if it works fine in development. This is not applicable to other platforms.
49
+
:::warning
50
+
51
+
If you are building for Android or iOS, do not skip this step, or your app may crash in production even if it works fine in development. This is not applicable to other platforms.
52
+
53
+
:::
50
54
51
55
3. If you're on a Mac and developing for iOS, you also need to install the pods (via [Cocoapods](https://cocoapods.org/)) to complete the linking.
52
56
@@ -75,7 +79,11 @@ function MyDrawer() {
75
79
}
76
80
```
77
81
78
-
> For a complete usage guide please visit [Drawer Navigation](drawer-based-navigation.md).
82
+
:::note
83
+
84
+
For a complete usage guide please visit [Drawer Navigation](drawer-based-navigation.md).
> Note: You might get warnings related to peer dependencies after installation. They are usually caused by incorrect version ranges specified in some packages. You can safely ignore most warnings as long as your app builds.
58
+
:::note
59
+
60
+
You might get warnings related to peer dependencies after installation. They are usually caused by incorrect version ranges specified in some packages. You can safely ignore most warnings as long as your app builds.
61
+
62
+
:::
59
63
60
64
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`.
61
65
@@ -89,7 +93,11 @@ import android.os.Bundle;
89
93
90
94
This change is required to avoid crashes related to View state being not persisted consistently across Activity restarts.
91
95
92
-
> 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.
96
+
:::info
97
+
98
+
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.
99
+
100
+
:::
93
101
94
102
## Wrapping your app in `NavigationContainer`
95
103
@@ -106,7 +114,11 @@ export default function App() {
106
114
}
107
115
```
108
116
109
-
> Note: In a typical React Native app, the `NavigationContainer` should be only used once in your app at the root. You shouldn't nest multiple `NavigationContainer`s unless you have a specific use case for them.
117
+
:::warning
118
+
119
+
In a typical React Native app, the `NavigationContainer` should be only used once in your app at the root. You shouldn't nest multiple `NavigationContainer`s unless you have a specific use case for them.
120
+
121
+
:::
110
122
111
123
Now you are ready to build and run your app on the device/simulator.
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/glossary-of-terms.md
+5-1
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,11 @@ title: Glossary of terms
4
4
sidebar_label: Glossary of terms
5
5
---
6
6
7
-
> This is a new section of the documentation and it's missing a lot of terms! Please [submit a pull request or an issue](https://github.com/react-navigation/react-navigation.github.io) with a term that you think should be explained here.
7
+
:::note
8
+
9
+
This is a new section of the documentation and it's missing a lot of terms! Please [submit a pull request or an issue](https://github.com/react-navigation/react-navigation.github.io) with a term that you think should be explained here.
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/handling-safe-area.md
+5-1
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,11 @@ It's tempting to solve (a) by wrapping your entire app in a container with paddi
23
23
24
24
While React Native exports a `SafeAreaView` component, this component only supports iOS 10+ with no support for older iOS versions or Android. In addition, it also has some issues, i.e. if a screen containing safe area is animating, it causes jumpy behavior. So we recommend to use the `useSafeAreaInsets` hook from the [react-native-safe-area-context](https://github.com/th3rdwave/react-native-safe-area-context) library to handle safe areas in a more reliable way.
25
25
26
-
> Note: The `react-native-safe-area-context` library also exports a `SafeAreaView` component. While it works on Android, it also has the same issues related to jumpy behavior when animating. So we recommend always using the `useSafeAreaInsets` hook instead and avoid using the `SafeAreaView` component.
26
+
:::warning
27
+
28
+
The `react-native-safe-area-context` library also exports a `SafeAreaView` component. While it works on Android, it also has the same issues related to jumpy behavior when animating. So we recommend always using the `useSafeAreaInsets` hook instead and avoid using the `SafeAreaView` component.
29
+
30
+
:::
27
31
28
32
The rest of this guide gives more information on how to support safe areas in React Navigation.
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/headers.md
+5-1
Original file line number
Diff line number
Diff line change
@@ -173,7 +173,11 @@ function StackScreen() {
173
173
}
174
174
```
175
175
176
-
> You might be wondering, why `headerTitle` when we provide a component and not `title`, like before? The reason is that `headerTitle` is a property that is specific to stack navigators, the `headerTitle` defaults to a `Text` component that displays the `title`.
176
+
:::note
177
+
178
+
You might be wondering, why `headerTitle` when we provide a component and not `title`, like before? The reason is that `headerTitle` is a property that is specific to headers, whereas `title` will be used for tab bars, drawers etc. as well. The `headerTitle` defaults to a `Text` component that displays the `title`.
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/hello-react-navigation.md
+15-3
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,11 @@ export default App;
63
63
64
64
If you run this code, you will see a screen with an empty navigation bar and a grey content area containing your `HomeScreen` component (shown above). The styles you see for the navigation bar and the content area are the default configuration for a stack navigator, we'll learn how to configure those later.
65
65
66
-
> The casing of the route name doesn't matter -- you can use lowercase `home` or capitalized `Home`, it's up to you. We prefer capitalizing our route names.
66
+
:::tip
67
+
68
+
The casing of the route name doesn't matter -- you can use lowercase `home` or capitalized `Home`, it's up to you. We prefer capitalizing our route names.
69
+
70
+
:::
67
71
68
72
### Configuring the navigator
69
73
@@ -100,7 +104,11 @@ Now our stack has two _routes_, a `Home` route and a `Details` route. A route ca
100
104
101
105
Here, the `Home` route corresponds to the `HomeScreen` component, and the `Details` route corresponds to the `DetailsScreen` component. The initial route for the stack is the `Home` route. Try changing it to `Details` and reload the app (React Native's Fast Refresh won't update changes from `initialRouteName`, as you might expect), notice that you will now see the `Details` screen. Then change it back to `Home` and reload once more.
102
106
103
-
> Note: The `component` prop accepts component, not a render function. Don't pass an inline function (e.g. `component={() => <HomeScreen />}`), or your component will unmount and remount losing all state when the parent component re-renders. See [Passing additional props](#passing-additional-props) for alternatives.
107
+
:::warning
108
+
109
+
The `component` prop accepts component, not a render function. Don't pass an inline function (e.g. `component={() => <HomeScreen />}`), or your component will unmount and remount losing all state when the parent component re-renders. See [Passing additional props](#passing-additional-props) for alternatives.
110
+
111
+
:::
104
112
105
113
### Specifying options
106
114
@@ -131,7 +139,11 @@ Sometimes we might want to pass additional props to a screen. We can do that wit
131
139
</Stack.Screen>
132
140
```
133
141
134
-
> Note: By default, React Navigation applies optimizations to screen components to prevent unnecessary renders. Using a render callback removes those optimizations. So if you use a render callback, you'll need to ensure that you use [`React.memo`](https://reactjs.org/docs/react-api.html#reactmemo) or [`React.PureComponent`](https://reactjs.org/docs/react-api.html#reactpurecomponent) for your screen components to avoid performance issues.
142
+
:::warning
143
+
144
+
By default, React Navigation applies optimizations to screen components to prevent unnecessary renders. Using a render callback removes those optimizations. So if you use a render callback, you'll need to ensure that you use [`React.memo`](https://reactjs.org/docs/react-api.html#reactmemo) or [`React.PureComponent`](https://reactjs.org/docs/react-api.html#reactpurecomponent) for your screen components to avoid performance issues.
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/material-bottom-tab-navigator.md
+10-2
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,11 @@ title: Material Bottom Tabs Navigator
4
4
sidebar_label: Material Bottom Tabs
5
5
---
6
6
7
-
> The `material-bottom-tabs` navigator is moved to [`react-native-paper`](https://reactnativepaper.com/). Refer to [`react-native-paper`'s documentation](https://callstack.github.io/react-native-paper/docs/components/BottomNavigation/createMaterialBottomTabNavigator) for API and usage. For any issues with the navigator, please open an issue in [`react-native-paper`'s repository](https://github.com/callstack/react-native-paper/).
7
+
:::warning
8
+
9
+
The `material-bottom-tabs` navigator is moved to [`react-native-paper`](https://reactnativepaper.com/). Refer to [`react-native-paper`'s documentation](https://callstack.github.io/react-native-paper/docs/components/BottomNavigation/createMaterialBottomTabNavigator) for API and usage. For any issues with the navigator, please open an issue in [`react-native-paper`'s repository](https://github.com/callstack/react-native-paper/).
10
+
11
+
:::
8
12
9
13
A material-design themed tab bar on the bottom of the screen that lets you switch between different routes with animation. Routes are lazily initialized - their screen components are not mounted until they are first focused.
10
14
@@ -47,7 +51,11 @@ function MyTabs() {
47
51
}
48
52
```
49
53
50
-
> For a complete usage guide please visit [Tab Navigation](tab-based-navigation.md)
54
+
:::note
55
+
56
+
For a complete usage guide please visit [Tab Navigation](tab-based-navigation.md)
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/navigating.md
+10-2
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,11 @@ Let's break this down:
56
56
-`navigation` - the `navigation` prop is passed in to every **screen component** ([definition](glossary-of-terms.md#screen-component)) in the native stack navigator (more about this later in ["The navigation prop in depth"](navigation-prop.md)).
57
57
-`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.
58
58
59
-
> If we call `navigation.navigate` with a route name that we haven't defined in a navigator, it'll print an error in development builds and nothing will happen in production builds. Said another way, we can only navigate to routes that have been defined on our navigator — we cannot navigate to an arbitrary component.
59
+
:::note
60
+
61
+
If we call `navigation.navigate` with a route name that we haven't defined in a navigator, it'll print an error in development builds and nothing will happen in production builds. Said another way, we can only navigate to routes that have been defined on our navigator — we cannot navigate to an arbitrary component.
62
+
63
+
:::
60
64
61
65
So we now have a stack with two routes: 1) the `Home` route 2) the `Details` route. What would happen if we navigated to the `Details` route again, from the `Details` screen?
62
66
@@ -123,7 +127,11 @@ function DetailsScreen({ navigation }) {
123
127
}
124
128
```
125
129
126
-
> On Android, React Navigation hooks in to the hardware back button and fires the `goBack()` function for you when the user presses it, so it behaves as the user would expect.
130
+
:::note
131
+
132
+
On Android, React Navigation hooks in to the hardware back button and fires the `goBack()` function for you when the user presses it, so it behaves as the user would expect.
133
+
134
+
:::
127
135
128
136
Another common requirement is to be able to go back _multiple_ screens -- for example, if you are several screens deep in a stack and want to dismiss all of them to go back to the first screen. In this case, we know that we want to go back to `Home` so we can use `navigate('Home')` (not `push`! try that out and see the difference). Another alternative would be `navigation.popToTop()`, which goes back to the first screen in the stack.
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/navigation-actions.md
+5-1
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,11 @@ navigation.dispatch(state => {
92
92
});
93
93
```
94
94
95
-
> Note: Consider the navigator's state object to be internal and subject to change in a minor release. Avoid using properties from the [navigation state](navigation-state.md) state object except `index` and `routes`, unless you really need it. If there is some functionality you cannot achieve without relying on the structure of the state object, please open an issue.
95
+
:::warning
96
+
97
+
Consider the navigator's state object to be internal and subject to change in a minor release. Avoid using properties from the [navigation state](navigation-state.md) state object except `index` and `routes`, unless you really need it. If there is some functionality you cannot achieve without relying on the structure of the state object, please open an issue.
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/navigation-container.md
+5-1
Original file line number
Diff line number
Diff line change
@@ -178,7 +178,11 @@ See [state persistence guide](state-persistence.md) for more details on how to p
178
178
179
179
### `onStateChange`
180
180
181
-
> Note: Consider the navigator's state object to be internal and subject to change in a minor release. Avoid using properties from the navigation state object except `index` and `routes`, unless you really need it. If there is some functionality you cannot achieve without relying on the structure of the state object, please open an issue.
181
+
:::warning
182
+
183
+
Consider the navigator's state object to be internal and subject to change in a minor release. Avoid using properties from the [navigation state](navigation-state.md) state object except `index` and `routes`, unless you really need it. If there is some functionality you cannot achieve without relying on the structure of the state object, please open an issue.
184
+
185
+
:::
182
186
183
187
Function that gets called every time [navigation state](navigation-state.md) changes. It receives the new navigation state as the argument.
0 commit comments