Skip to content

Commit 8c4d96f

Browse files
committed
Use tabs for Expo vs Community CLI
1 parent 8c088e8 commit 8c4d96f

File tree

7 files changed

+188
-129
lines changed

7 files changed

+188
-129
lines changed

versioned_docs/version-7.x/deep-linking.md

Lines changed: 76 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ While you don't need to use the `linking` prop from React Navigation, and can ha
1818

1919
Below, we'll go through required configurations so that the deep link integration works.
2020

21-
## Setup with Expo projects
21+
## Setting up deep links
22+
23+
<Tabs groupId='framework' queryString="framework">
24+
<TabItem value='expo' label='Expo' default>
25+
26+
### Configuring URL scheme
2227

2328
First, you will want to specify a URL scheme for your app. This corresponds to the string before `://` in a URL, so if your scheme is `example` then a link to your app would be `example://`. You can register for a scheme in your `app.json` by adding a string under the scheme key:
2429

@@ -36,55 +41,25 @@ Next, install `expo-linking` which we'd need to get the deep link prefix:
3641
npx expo install expo-linking
3742
```
3843

39-
Then, let's configure React Navigation to use the `scheme` for parsing incoming deep links:
40-
41-
<Tabs groupId="config" queryString="config">
42-
<TabItem value="static" label="Static" default>
44+
Then you can use `Linking.createURL` to get the prefix for your app:
4345

4446
```js
45-
import * as Linking from 'expo-linking';
46-
47-
const prefix = Linking.createURL('/');
48-
49-
/* content */
50-
51-
function App() {
52-
const linking = {
53-
prefixes: [prefix],
54-
};
55-
56-
return <Navigation linking={linking} />;
57-
}
47+
const linking = {
48+
prefixes: [Linking.createURL('/'),
49+
};
5850
```
5951

60-
</TabItem>
61-
<TabItem value="dynamic" label="Dynamic">
62-
63-
```js
64-
import * as Linking from 'expo-linking';
52+
See more details below at [Configuring React Navigation](#configuring-react-navigation).
6553

66-
const prefix = Linking.createURL('/');
67-
68-
function App() {
69-
const linking = {
70-
prefixes: [prefix],
71-
};
72-
73-
return (
74-
<NavigationContainer linking={linking} fallback={<Text>Loading...</Text>}>
75-
{/* content */}
76-
</NavigationContainer>
77-
);
78-
}
79-
```
80-
81-
</TabItem>
82-
</Tabs>
54+
<details>
55+
<summary>Why use `Linking.createURL`?</summary>
8356

8457
It is necessary to use `Linking.createURL` since the scheme differs between the [Expo Dev Client](https://docs.expo.dev/versions/latest/sdk/dev-client/) and standalone apps.
8558

8659
The scheme specified in `app.json` only applies to standalone apps. In the Expo client app you can deep link using `exp://ADDRESS:PORT/--/` where `ADDRESS` is often `127.0.0.1` and `PORT` is often `19000` - the URL is printed when you run `expo start`. The `Linking.createURL` function abstracts it out so that you don't need to specify them manually.
8760

61+
</details>
62+
8863
If you are using universal links, you need to add your domain to the prefixes as well:
8964

9065
```js
@@ -93,7 +68,7 @@ const linking = {
9368
};
9469
```
9570

96-
### Universal Links on Expo
71+
### Universal Links on iOS
9772

9873
To set up iOS universal Links in your Expo app, you need to configure your [app config](https://docs.expo.dev/workflow/configuration) to include the associated domains and entitlements:
9974

@@ -114,7 +89,7 @@ You will also need to setup [Associated Domains](https://developer.apple.com/doc
11489

11590
See [Expo's documentation on iOS Universal Links](https://docs.expo.dev/linking/ios-universal-links/) for more details.
11691

117-
### App Links on Expo
92+
### App Links on Android
11893

11994
To set up Android App Links in your Expo app, you need to configure your [app config](https://docs.expo.dev/workflow/configuration) to include the `intentFilters`:
12095

@@ -144,7 +119,8 @@ You will also need to [declare the association](https://developer.android.com/tr
144119

145120
See [Expo's documentation on Android App Links](https://docs.expo.dev/linking/android-app-links/) for more details.
146121

147-
## Set up with bare React Native projects
122+
</TabItem>
123+
<TabItem value='community-cli' label='Community CLI'>
148124

149125
### Setup on iOS
150126

@@ -300,6 +276,63 @@ After adding them, it should look like this:
300276

301277
Then, you need to [declare the association](https://developer.android.com/training/app-links/verify-android-applinks#web-assoc) between your website and your intent filters by hosting a Digital Asset Links JSON file.
302278

279+
</TabItem>
280+
</Tabs>
281+
282+
## Configuring React Navigation
283+
284+
To handle deep links, you need to configure React Navigation to use the `scheme` for parsing incoming deep links:
285+
286+
<Tabs groupId="config" queryString="config">
287+
<TabItem value="static" label="Static" default>
288+
289+
```js
290+
const linking = {
291+
prefixes: [
292+
'example://', // Or `Linking.createURL('/')` for Expo apps
293+
],
294+
};
295+
296+
function App() {
297+
return <Navigation linking={linking} />;
298+
}
299+
```
300+
301+
</TabItem>
302+
<TabItem value="dynamic" label="Dynamic">
303+
304+
```js
305+
const linking = {
306+
prefixes: [
307+
'example://', // Or `Linking.createURL('/')` for Expo apps
308+
],
309+
};
310+
311+
function App() {
312+
return (
313+
<NavigationContainer linking={linking} fallback={<Text>Loading...</Text>}>
314+
{/* content */}
315+
</NavigationContainer>
316+
);
317+
}
318+
```
319+
320+
</TabItem>
321+
</Tabs>
322+
323+
If you are using universal links, you need to add your domain to the prefixes as well:
324+
325+
```js
326+
const linking = {
327+
prefixes: [
328+
'example://', // Or `Linking.createURL('/')` for Expo apps
329+
'https://app.example.com',
330+
],
331+
};
332+
```
333+
334+
See [configuring links](configuring-links.md) to see further details on how to configure links in React Navigation.
335+
303336
## Testing deep links
304337

305338
Before testing deep links, make sure that you rebuild and install the app in your emulator/simulator/device.

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,36 @@ To use this package, open a Terminal in the project root and run:
2020
npm install react-native-drawer-layout
2121
```
2222

23-
Then, you need to install and configure the libraries that are required by the drawer:
23+
The library depends on [`react-native-gesture-handler`](https://docs.swmansion.com/react-native-gesture-handler/) for gestures and [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/) for animations.
2424

25-
1. First, install [`react-native-gesture-handler`](https://docs.swmansion.com/react-native-gesture-handler/) and [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/) (at least version 2 or 3).
25+
<Tabs groupId='framework' queryString="framework">
26+
<TabItem value='expo' label='Expo' default>
2627

27-
If you have a Expo managed project, in your project directory, run:
28+
If you have a Expo managed project, in your project directory, run:
2829

29-
```bash
30-
npx expo install react-native-gesture-handler react-native-reanimated react-native-worklets
31-
```
30+
```bash
31+
npx expo install react-native-gesture-handler react-native-reanimated react-native-worklets
32+
```
3233

33-
If you have a bare React Native project, in your project directory, run:
34+
</TabItem>
35+
<TabItem value='community-cli' label='Community CLI'>
3436

35-
```bash npm2yarn
36-
npm install react-native-gesture-handler react-native-reanimated react-native-worklets
37-
```
37+
If you have a bare React Native project, in your project directory, run:
3838

39-
2. Configure the Reanimated Babel Plugin in your project following the [installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started).
39+
```bash npm2yarn
40+
npm install react-native-gesture-handler react-native-reanimated react-native-worklets
41+
```
4042

41-
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.
43+
After installation, configure the Reanimated Babel Plugin in your project following the [installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started).
4244

43-
```bash
44-
npx pod-install ios
45-
```
45+
</TabItem>
46+
</Tabs>
4647

47-
We're done! Now you can build and run the app on your device/simulator.
48+
If you're on a Mac and developing for iOS, you also need to install [pods](https://cocoapods.org/) to complete the linking.
49+
50+
```bash
51+
npx pod-install ios
52+
```
4853

4954
## Quick start
5055

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

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,36 @@ To use this navigator, ensure that you have [`@react-navigation/native` and its
2020
npm install @react-navigation/drawer
2121
```
2222

23-
Then, you need to install and configure the libraries that are required by the drawer navigator:
23+
The navigator depends on [`react-native-gesture-handler`](https://docs.swmansion.com/react-native-gesture-handler/) for gestures and [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/) for animations.
2424

25-
1. First, install [`react-native-gesture-handler`](https://docs.swmansion.com/react-native-gesture-handler/) and [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/) (at least version 2 or 3).
25+
<Tabs groupId='framework' queryString="framework">
26+
<TabItem value='expo' label='Expo' default>
2627

27-
If you have a Expo managed project, in your project directory, run:
28+
If you have a Expo managed project, in your project directory, run:
2829

29-
```bash
30-
npx expo install react-native-gesture-handler react-native-reanimated react-native-worklets
31-
```
30+
```bash
31+
npx expo install react-native-gesture-handler react-native-reanimated react-native-worklets
32+
```
3233

33-
If you have a bare React Native project, in your project directory, run:
34+
</TabItem>
35+
<TabItem value='community-cli' label='Community CLI'>
3436

35-
```bash npm2yarn
36-
npm install react-native-gesture-handler react-native-reanimated react-native-worklets
37-
```
37+
If you have a bare React Native project, in your project directory, run:
3838

39-
2. Configure the Reanimated Babel Plugin in your project following the [installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started).
39+
```bash npm2yarn
40+
npm install react-native-gesture-handler react-native-reanimated react-native-worklets
41+
```
4042

41-
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.
43+
After installation, configure the Reanimated Babel Plugin in your project following the [installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started).
4244

43-
```bash
44-
npx pod-install ios
45-
```
45+
</TabItem>
46+
</Tabs>
47+
48+
If you're on a Mac and developing for iOS, you also need to install [pods](https://cocoapods.org/) to complete the linking.
49+
50+
```bash
51+
npx pod-install ios
52+
```
4653

4754
## Usage
4855

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

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,54 +42,44 @@ Otherwise, you can follow the instructions below to install React Navigation int
4242

4343
## Installation
4444

45-
Install the required packages in your React Native project:
45+
The `@react-navigation/native` package contains the core functionality of React Navigation.
46+
47+
In your project directory, run:
4648

4749
```bash npm2yarn
4850
npm install @react-navigation/native
4951
```
5052

51-
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.
53+
### Installing dependencies
5254

53-
The libraries we will install now are [`react-native-screens`](https://github.com/software-mansion/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.
55+
Let's also install and configure dependencies used by most navigators. The libraries we will install now are [`react-native-screens`](https://github.com/software-mansion/react-native-screens) and [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context).
5456

55-
### Installing dependencies into an Expo managed project
57+
<Tabs groupId='framework' queryString="framework">
58+
<TabItem value='expo' label='Expo' default>
5659

5760
In your project directory, run:
5861

5962
```bash
6063
npx expo install react-native-screens react-native-safe-area-context
6164
```
6265

63-
This will install versions of these libraries that are compatible.
64-
65-
You can now continue to ["Hello React Navigation"](hello-react-navigation.md) to start writing some code.
66+
This will install versions of these libraries that are compatible with your Expo SDK version.
6667

67-
### Installing dependencies into a bare React Native project
68+
</TabItem>
69+
<TabItem value='community-cli' label='Community CLI'>
6870

6971
In your project directory, run:
7072

7173
```bash npm2yarn
7274
npm install react-native-screens react-native-safe-area-context
7375
```
7476

75-
:::note
76-
77-
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 these warnings as long as your app builds and works as expected.
78-
79-
:::
80-
8177
If you're on a Mac and developing for iOS, you need to install the pods (via [Cocoapods](https://cocoapods.org/)) to complete the linking.
8278

8379
```bash
8480
npx pod-install ios
8581
```
8682

87-
:::info
88-
89-
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.
90-
91-
:::
92-
9383
#### Configuring `react-native-screens` on Android
9484

9585
[`react-native-screens`](https://github.com/software-mansion/react-native-screens) requires one additional configuration to properly work on Android.
@@ -119,8 +109,8 @@ class MainActivity: ReactActivity() {
119109
}
120110
```
121111

122-
</TabItem>
123-
<TabItem value='java' label='Java'>
112+
</TabItem>
113+
<TabItem value='java' label='Java'>
124114

125115
```java
126116
// highlight-start
@@ -163,12 +153,21 @@ To opt out, in `AndroidManifest.xml`, in the `<application>` tag (or `<activity>
163153
</application>
164154
```
165155

156+
</TabItem>
157+
</Tabs>
158+
166159
## Setting up React Navigation
167160

168161
Once you've installed and configured the dependencies, you can move on to setting up your project to use React Navigation.
169162

170163
When using React Navigation, you configure [**navigators**](glossary-of-terms.md#navigator) in your app. Navigators handle the transition between screens in your app and provide UI such as header, tab bar etc.
171164

165+
:::info
166+
167+
When you use a navigator (such as stack navigator), you'll need to follow the installation instructions of that navigator for any additional dependencies.
168+
169+
:::
170+
172171
There are 2 primary ways to configure the navigators:
173172

174173
### Static configuration

0 commit comments

Comments
 (0)