Skip to content

Commit

Permalink
Update instructions for importing gesture handler
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Jul 14, 2024
1 parent de04713 commit 7f13def
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 30 deletions.
23 changes: 18 additions & 5 deletions versioned_docs/version-6.x/drawer-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,25 @@ Then, you need to install and configure the libraries that are required by the d

The Drawer supports both Reanimated 1 and the latest version of Reanimated. If you want to use the latest version of Reanimated, make sure to configure it following the [installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started).

2. To finalize installation of `react-native-gesture-handler`, 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`:
2. To finalize the installation of `react-native-gesture-handler`, we need to conditionally import it. To do this, create 2 files:

```js
```js title="gesture-handler.native.js"
// Only import react-native-gesture-handler on native platforms
import 'react-native-gesture-handler';
```

```js title="gesture-handler.js"
// Don't import react-native-gesture-handler on web
```
Now, 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`:
```js
import './gesture-handler';
```
Since the drawer layout doesn't use `react-native-gesture-handler` on the web, this avoids unnecessarily increasing the bundle size.
:::warning
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.
Expand All @@ -52,9 +65,9 @@ Then, you need to install and configure the libraries that are required by the d
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.
```bash
npx pod-install ios
```
```bash
npx pod-install ios
```
We're done! Now you can build and run the app on your device/simulator.
Expand Down
23 changes: 18 additions & 5 deletions versioned_docs/version-6.x/drawer-navigator.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,25 @@ Then, you need to install and configure the libraries that are required by the d

The Drawer supports both Reanimated 1 and the latest version of Reanimated. If you want to use the latest version of Reanimated, make sure to configure it following the [installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started).

2. To finalize installation of `react-native-gesture-handler`, 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`:
2. To finalize the installation of `react-native-gesture-handler`, we need to conditionally import it. To do this, create 2 files:

```js
```js title="gesture-handler.native.js"
// Only import react-native-gesture-handler on native platforms
import 'react-native-gesture-handler';
```

```js title="gesture-handler.js"
// Don't import react-native-gesture-handler on web
```
Now, 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`:
```js
import './gesture-handler';
```
Since the drawer navigator doesn't use `react-native-gesture-handler` on the web, this avoids unnecessarily increasing the bundle size.
:::warning
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.
Expand All @@ -52,9 +65,9 @@ Then, you need to install and configure the libraries that are required by the d
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.
```bash
npx pod-install ios
```
```bash
npx pod-install ios
```
## API Definition
Expand Down
23 changes: 18 additions & 5 deletions versioned_docs/version-6.x/stack-navigator.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,25 @@ Then, you need to install and configure the libraries that are required by the s
npm install react-native-gesture-handler
```

2. To finalize installation of `react-native-gesture-handler`, 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`:
2. To finalize the installation of `react-native-gesture-handler`, we need to conditionally import it. To do this, create 2 files:

```js
```js title="gesture-handler.native.js"
// Only import react-native-gesture-handler on native platforms
import 'react-native-gesture-handler';
```

```js title="gesture-handler.js"
// Don't import react-native-gesture-handler on web
```
Now, 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`:
```js
import './gesture-handler';
```
Since the stack navigator doesn't use `react-native-gesture-handler` on the web, this avoids unnecessarily increasing the bundle size.
:::warning
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.
Expand All @@ -66,9 +79,9 @@ Then, you need to install and configure the libraries that are required by the s
4. 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.
```bash
npx pod-install ios
```
```bash
npx pod-install ios
```
## API Definition
Expand Down
23 changes: 18 additions & 5 deletions versioned_docs/version-7.x/drawer-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,25 @@ Then, you need to install and configure the libraries that are required by the d

2. Configure the Reanimated Babel Plugin in your project following the [installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started).

3. To finalize the installation of `react-native-gesture-handler`, 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`:
3. To finalize the installation of `react-native-gesture-handler`, we need to conditionally import it. To do this, create 2 files:

```js
```js title="gesture-handler.native.js"
// Only import react-native-gesture-handler on native platforms
import 'react-native-gesture-handler';
```

```js title="gesture-handler.js"
// Don't import react-native-gesture-handler on web
```
Now, 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`:
```js
import './gesture-handler';
```
Since the drawer layout doesn't use `react-native-gesture-handler` on the web, this avoids unnecessarily increasing the bundle size.
:::warning
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.
Expand All @@ -52,9 +65,9 @@ Then, you need to install and configure the libraries that are required by the d
4. 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.
```bash
npx pod-install ios
```
```bash
npx pod-install ios
```
We're done! Now you can build and run the app on your device/simulator.
Expand Down
23 changes: 18 additions & 5 deletions versioned_docs/version-7.x/drawer-navigator.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,25 @@ Then, you need to install and configure the libraries that are required by the d

2. Configure the Reanimated Babel Plugin in your project following the [installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started).

3. To finalize the installation of `react-native-gesture-handler`, 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`:
3. To finalize the installation of `react-native-gesture-handler`, we need to conditionally import it. To do this, create 2 files:

```js
```js title="gesture-handler.native.js"
// Only import react-native-gesture-handler on native platforms
import 'react-native-gesture-handler';
```

```js title="gesture-handler.js"
// Don't import react-native-gesture-handler on web
```
Now, 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`:
```js
import './gesture-handler';
```
Since the drawer navigator doesn't use `react-native-gesture-handler` on the web, this avoids unnecessarily increasing the bundle size.
:::warning
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.
Expand All @@ -52,9 +65,9 @@ Then, you need to install and configure the libraries that are required by the d
4. 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.
```bash
npx pod-install ios
```
```bash
npx pod-install ios
```
## Usage
Expand Down
23 changes: 18 additions & 5 deletions versioned_docs/version-7.x/stack-navigator.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,25 @@ Then, you need to install and configure the libraries that are required by the s
npm install react-native-gesture-handler
```

2. To finalize installation of `react-native-gesture-handler`, 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`:
2. To finalize the installation of `react-native-gesture-handler`, we need to conditionally import it. To do this, create 2 files:

```js
```js title="gesture-handler.native.js"
// Only import react-native-gesture-handler on native platforms
import 'react-native-gesture-handler';
```

```js title="gesture-handler.js"
// Don't import react-native-gesture-handler on web
```
Now, 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`:
```js
import './gesture-handler';
```
Since the stack navigator doesn't use `react-native-gesture-handler` on the web, this avoids unnecessarily increasing the bundle size.
:::warning
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.
Expand All @@ -70,9 +83,9 @@ Then, you need to install and configure the libraries that are required by the s
4. 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.
```bash
npx pod-install ios
```
```bash
npx pod-install ios
```
## Usage
Expand Down

0 comments on commit 7f13def

Please sign in to comment.