Skip to content

Commit 5c8065c

Browse files
committed
Add documentation for the static API
1 parent 354263d commit 5c8065c

File tree

10 files changed

+969
-3
lines changed

10 files changed

+969
-3
lines changed

versioned_docs/version-6.x/screen.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,7 @@ This can be useful when we have some screens which we want to be removed or rese
147147
component={ProfileScreen}
148148
/>
149149
```
150+
151+
### `listeners`
152+
153+
Event listeners to subscribe to. See [`listeners` prop on `Screen`](navigation-events.md#listeners-prop-on-screen) for more details.

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ It's important to note that when using such a setup, you **don't manually naviga
5757
In our navigator, we can conditionally define appropriate screens. For our case, let's say we have 3 screens:
5858

5959
- `SplashScreen` - This will show a splash or loading screen when we're restoring the token.
60-
- `SignInScreen` - This is the screen we show if the user isn't signed in already (we couldn't find a token).
61-
- `HomeScreen` - This is the screen we show if the user is already signed in.
60+
- `SignIn` - This is the screen we show if the user isn't signed in already (we couldn't find a token).
61+
- `Home` - This is the screen we show if the user is already signed in.
6262

6363
So our navigator will look like:
6464

@@ -141,6 +141,12 @@ import * as React from 'react';
141141
const AuthContext = React.createContext();
142142
```
143143

144+
In our component, we will:
145+
146+
- Store the token and loading state in `useReducer`
147+
- Persist it to `SecureStore` and read it from there on app launch
148+
- Expose the methods for sign in and sign out to child components using `AuthContext`
149+
144150
So our component will look like this:
145151

146152
<samp id="auth-flow" />
@@ -192,6 +198,7 @@ export default function App({ navigation }) {
192198
}
193199

194200
// After restoring token, we may need to validate it in production apps
201+
// ...
195202

196203
// This will switch to the App screen or Auth screen and this loading
197204
// screen will be unmounted and thrown away.
@@ -224,6 +231,10 @@ export default function App({ navigation }) {
224231
[]
225232
);
226233

234+
if (state.isLoading) {
235+
return <SplashScreen />;
236+
}
237+
227238
return (
228239
<AuthContext.Provider value={authContext}>
229240
<Stack.Navigator>
@@ -268,6 +279,8 @@ function SignInScreen() {
268279
}
269280
```
270281

282+
You can similarly fill in the other screens according to your requirements.
283+
271284
## Removing shared screens when auth state changes
272285

273286
Consider the following example:

versioned_docs/version-7.x/migration-guides.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar_label: Migration Guides
66

77
This page contains links to pages that will guide you through the process of upgrading React Navigation:
88

9-
- [Upgrading from 6.x to 7.x](../version-6.x/upgrading-from-6.x.md)
9+
- [Upgrading from 6.x to 7.x](../version-7.x/upgrading-from-6.x.md)
1010
- [Upgrading from 5.x to 6.x](../version-6.x/upgrading-from-5.x.md)
1111
- [Upgrading from 4.x to 5.x](../version-5.x/upgrading-from-4.x.md)
1212
- [Upgrading from 3.x to 4.x](../version-4.x/upgrading-from-3.x.md)

versioned_docs/version-7.x/screen.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,7 @@ This can be useful when we have some screens which we want to be removed or rese
147147
component={ProfileScreen}
148148
/>
149149
```
150+
151+
### `listeners`
152+
153+
Event listeners to subscribe to. See [`listeners` prop on `Screen`](navigation-events.md#listeners-prop-on-screen) for more details.

0 commit comments

Comments
 (0)