Skip to content

Commit 8fabf6d

Browse files
committed
Use admonitions syntax for notes
1 parent f6d409a commit 8fabf6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+455
-97
lines changed

versioned_docs/version-6.x/MST-integration.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ title: Integrating with MobX State Tree
44
sidebar_label: MobX State Tree integration
55
---
66

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+
:::
812

913
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.
1014

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!
18+
19+
:::
1220

1321
## Overview
1422

versioned_docs/version-6.x/auth-flow.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ Most apps require that a user authenticates in some way to have access to data a
1111
- 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.
1212
- When the user signs out, we clear the authentication state and send them back to authentication screens.
1313

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+
:::
1519

1620
## What we need
1721

@@ -118,11 +122,19 @@ state.userToken == null ? (
118122
);
119123
```
120124

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+
:::
122130

123131
## Implement the logic for restoring the token
124132

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+
:::
126138

127139
From the previous snippet, we can see that we need 3 state variables:
128140

versioned_docs/version-6.x/bottom-tab-navigator.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ function MyTabs() {
4141
}
4242
```
4343

44-
> For a complete usage guide please visit [Tab Navigation](tab-based-navigation.md)
44+
:::note
45+
46+
For a complete usage guide please visit [Tab Navigation](tab-based-navigation.md)
47+
48+
:::
4549

4650
### Props
4751

versioned_docs/version-6.x/configuring-links.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ function App() {
3737

3838
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.
3939

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+
:::
4145

4246
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.
4347

versioned_docs/version-6.x/devtools.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ The package exposes the following APIs:
2222

2323
This hook provides integration with [Flipper](https://fbflipper.com/) for React Native apps.
2424

25-
> This doesn't work in Expo managed apps since they don't support Flipper.
25+
:::warning
26+
27+
This doesn't work in Expo managed apps since they don't support Flipper.
28+
29+
:::
2630

2731
To be able to use this hook, you need to:
2832

versioned_docs/version-6.x/drawer-layout.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ Then, you need to install and configure the libraries that are required by the d
4646
import 'react-native-gesture-handler';
4747
```
4848

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+
:::
5054

5155
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.
5256

versioned_docs/version-6.x/drawer-navigator.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ Then, you need to install and configure the libraries that are required by the d
4646
import 'react-native-gesture-handler';
4747
```
4848

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+
:::
5054

5155
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.
5256

@@ -75,7 +79,11 @@ function MyDrawer() {
7579
}
7680
```
7781

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).
85+
86+
:::
7987

8088
### Props
8189

versioned_docs/version-6.x/getting-started.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ In your project directory, run:
5555
npm install react-native-screens react-native-safe-area-context
5656
```
5757

58-
> 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+
:::
5963

6064
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`.
6165

@@ -89,7 +93,11 @@ import android.os.Bundle;
8993

9094
This change is required to avoid crashes related to View state being not persisted consistently across Activity restarts.
9195

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+
:::
93101

94102
## Wrapping your app in `NavigationContainer`
95103

@@ -106,7 +114,11 @@ export default function App() {
106114
}
107115
```
108116

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+
:::
110122

111123
Now you are ready to build and run your app on the device/simulator.
112124

versioned_docs/version-6.x/glossary-of-terms.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ title: Glossary of terms
44
sidebar_label: Glossary of terms
55
---
66

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.
10+
11+
:::
812

913
## Navigator
1014

versioned_docs/version-6.x/handling-safe-area.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ It's tempting to solve (a) by wrapping your entire app in a container with paddi
2323

2424
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.
2525

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+
:::
2731

2832
The rest of this guide gives more information on how to support safe areas in React Navigation.
2933

versioned_docs/version-6.x/headers.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ function StackScreen() {
173173
}
174174
```
175175

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`.
179+
180+
:::
177181

178182
## Additional configuration
179183

versioned_docs/version-6.x/hello-react-navigation.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ export default App;
6363

6464
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.
6565

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+
:::
6771

6872
### Configuring the navigator
6973

@@ -100,7 +104,11 @@ Now our stack has two _routes_, a `Home` route and a `Details` route. A route ca
100104

101105
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.
102106

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+
:::
104112

105113
### Specifying options
106114

@@ -131,7 +139,11 @@ Sometimes we might want to pass additional props to a screen. We can do that wit
131139
</Stack.Screen>
132140
```
133141

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.
145+
146+
:::
135147

136148
## What's next?
137149

versioned_docs/version-6.x/material-bottom-tab-navigator.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ title: Material Bottom Tabs Navigator
44
sidebar_label: Material Bottom Tabs
55
---
66

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+
:::
812

913
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.
1014

@@ -47,7 +51,11 @@ function MyTabs() {
4751
}
4852
```
4953

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)
57+
58+
:::
5159

5260
## RouteConfigs
5361

versioned_docs/version-6.x/material-top-tab-navigator.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ function MyTabs() {
6363
}
6464
```
6565

66-
> For a complete usage guide please visit [Tab Navigation](tab-based-navigation.md)
66+
:::note
67+
68+
For a complete usage guide please visit [Tab Navigation](tab-based-navigation.md)
69+
70+
:::
6771

6872
### Props
6973

versioned_docs/version-6.x/navigating.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ Let's break this down:
5656
- `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)).
5757
- `navigate('Details')` - we call the `navigate` function (on the `navigation` prop &mdash; naming is hard!) with the name of the route that we'd like to move the user to.
5858

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 &mdash; 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 &mdash; we cannot navigate to an arbitrary component.
62+
63+
:::
6064

6165
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?
6266

@@ -123,7 +127,11 @@ function DetailsScreen({ navigation }) {
123127
}
124128
```
125129

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+
:::
127135

128136
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.
129137

versioned_docs/version-6.x/navigation-actions.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ navigation.dispatch(state => {
9292
});
9393
```
9494

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.
98+
99+
:::
96100

97101
### goBack
98102

versioned_docs/version-6.x/navigation-container.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ See [state persistence guide](state-persistence.md) for more details on how to p
178178

179179
### `onStateChange`
180180

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+
:::
182186

183187
Function that gets called every time [navigation state](navigation-state.md) changes. It receives the new navigation state as the argument.
184188

0 commit comments

Comments
 (0)