diff --git a/blog/2018-04-06-react-navigation-2.0-rc.md b/blog/2018-04-06-react-navigation-2.0-rc.md index 5050bffcfca..6f0d65da248 100644 --- a/blog/2018-04-06-react-navigation-2.0-rc.md +++ b/blog/2018-04-06-react-navigation-2.0-rc.md @@ -11,7 +11,7 @@ Exactly two months after the release of React Navigation 1.0, we are close to an -```sh +```bash yarn add react-navigation@^2.0.0-rc.1 ``` diff --git a/blog/2021-03-12-react-navigation-6.0-next.md b/blog/2021-03-12-react-navigation-6.0-next.md index a91403b81c4..6ac0e8219bb 100644 --- a/blog/2021-03-12-react-navigation-6.0-next.md +++ b/blog/2021-03-12-react-navigation-6.0-next.md @@ -29,7 +29,7 @@ We'll share few highlights of the release in this blog post. If you're looking f If you'd like to try it out, add `@^6.x` to the package, you're installing. For example: -```sh npm2yarn +```bash npm2yarn npm install @react-navigation/native@^6.x @react-navigation/stack@^6.x ``` diff --git a/static/assets/libraries/tab-view.gif b/static/assets/libraries/tab-view.gif new file mode 100644 index 00000000000..ac8e3574a0c Binary files /dev/null and b/static/assets/libraries/tab-view.gif differ diff --git a/versioned_docs/version-1.x/deep-linking.md b/versioned_docs/version-1.x/deep-linking.md index 9c42d51bfa6..4e3b7e229aa 100644 --- a/versioned_docs/version-1.x/deep-linking.md +++ b/versioned_docs/version-1.x/deep-linking.md @@ -120,7 +120,7 @@ In Xcode, open the project at `SimpleApp/ios/SimpleApp.xcodeproj`. Select the pr Now you can press play in Xcode, or re-build on the command line: -```sh +```bash react-native run-ios ``` @@ -160,7 +160,7 @@ In `SimpleApp/android/app/src/main/AndroidManifest.xml`, do these followings adj Now, re-install the app: -```sh +```bash react-native run-android ``` diff --git a/versioned_docs/version-2.x/deep-linking.md b/versioned_docs/version-2.x/deep-linking.md index 451eb587982..e0e0f6f3854 100644 --- a/versioned_docs/version-2.x/deep-linking.md +++ b/versioned_docs/version-2.x/deep-linking.md @@ -120,7 +120,7 @@ In Xcode, open the project at `SimpleApp/ios/SimpleApp.xcodeproj`. Select the pr Now you can press play in Xcode, or re-build on the command line: -```sh +```bash react-native run-ios ``` @@ -160,7 +160,7 @@ In `SimpleApp/android/app/src/main/AndroidManifest.xml`, do these followings adj Now, re-install the app: -```sh +```bash react-native run-android ``` diff --git a/versioned_docs/version-3.x/deep-linking.md b/versioned_docs/version-3.x/deep-linking.md index d66e34b3b38..7adc9312c4d 100644 --- a/versioned_docs/version-3.x/deep-linking.md +++ b/versioned_docs/version-3.x/deep-linking.md @@ -155,7 +155,7 @@ In Xcode, open the project at `SimpleApp/ios/SimpleApp.xcodeproj`. Select the pr Now you can press play in Xcode, or re-build on the command line: -```sh +```bash react-native run-ios ``` @@ -195,7 +195,7 @@ In `SimpleApp/android/app/src/main/AndroidManifest.xml`, do these followings adj Now, re-install the app: -```sh +```bash react-native run-android ``` diff --git a/versioned_docs/version-3.x/getting-started.md b/versioned_docs/version-3.x/getting-started.md index dee163efa76..b4150003183 100644 --- a/versioned_docs/version-3.x/getting-started.md +++ b/versioned_docs/version-3.x/getting-started.md @@ -44,7 +44,7 @@ Next, if you are not using the Expo managed workflow then you need to link these On iOS, to complete the linking, make sure you have [Cocoapods](https://cocoapods.org/) installed. Then run: - ```sh + ```bash cd ios pod install cd .. @@ -56,7 +56,7 @@ Next, if you are not using the Expo managed workflow then you need to link these If you're on an older React Native version, you need to manually link the dependencies. To do that, run: - ```sh + ```bash react-native link react-native-reanimated react-native link react-native-gesture-handler ``` diff --git a/versioned_docs/version-4.x/deep-linking.md b/versioned_docs/version-4.x/deep-linking.md index db4a13a023f..60536603b43 100644 --- a/versioned_docs/version-4.x/deep-linking.md +++ b/versioned_docs/version-4.x/deep-linking.md @@ -101,7 +101,7 @@ The reason that is necessary to use `Linking.createURL` is that the scheme will To test the URI on the simulator in the Expo client app, run the following: -```sh +```bash xcrun simctl openurl booted [ put your URI prefix in here ] // for example @@ -113,7 +113,7 @@ xcrun simctl openurl booted exp://127.0.0.1:19000/--/chat/Eric To test the intent handling in the Expo client app on Android, run the following: -```sh +```bash adb shell am start -W -a android.intent.action.VIEW -d "[ put your URI prefix in here ]" host.exp.exponent # for example @@ -145,7 +145,7 @@ Let's configure the native iOS app to open based on the `mychat://` URI scheme. In `SimpleApp/ios/SimpleApp/AppDelegate.m`: -```sh +```bash // Add the header at the top of the file: #import @@ -163,13 +163,13 @@ In Xcode, open the project at `SimpleApp/ios/SimpleApp.xcodeproj`. Select the pr Now you can press play in Xcode, or re-build on the command line: -```sh +```bash react-native run-ios ``` To test the URI on the simulator, run the following: -```sh +```bash xcrun simctl openurl booted mychat://chat/Eric ``` @@ -184,7 +184,7 @@ In `SimpleApp/android/app/src/main/AndroidManifest.xml`, do these followings adj 1. Set `launchMode` of `MainActivity` to `singleTask` in order to receive intent on existing `MainActivity`. It is useful if you want to perform navigation using deep link you have been registered - [details](http://developer.android.com/training/app-indexing/deep-linking.html#adding-filters) 2. Add the new `intent-filter` inside the `MainActivity` entry with a `VIEW` type action: -```sh +```bash @@ -203,13 +203,13 @@ In `SimpleApp/android/app/src/main/AndroidManifest.xml`, do these followings adj Now, re-install the app: -```sh +```bash react-native run-android ``` To test the intent handling in Android, run the following: -```sh +```bash adb shell am start -W -a android.intent.action.VIEW -d "mychat://chat/Eric" com.simpleapp ``` diff --git a/versioned_docs/version-4.x/getting-started.md b/versioned_docs/version-4.x/getting-started.md index 93f940bc556..7e5f8f01c79 100644 --- a/versioned_docs/version-4.x/getting-started.md +++ b/versioned_docs/version-4.x/getting-started.md @@ -40,7 +40,7 @@ The libraries we will install now are [`react-native-gesture-handler`](https://g In your project directory, run: -```sh +```bash npx expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view ``` @@ -66,7 +66,7 @@ Next, we need to link these libraries. The steps depends on your React Native ve If you're on a Mac and developing for iOS, you need to install pods to complete the linking. Make sure you have [Cocoapods](https://cocoapods.org/) installed. Then run: - ```sh + ```bash cd ios; pod install; cd .. ``` @@ -74,7 +74,7 @@ Next, we need to link these libraries. The steps depends on your React Native ve If you're on an older React Native version, you need to manually link the dependencies. To do that, run: - ```sh + ```bash react-native link react-native-reanimated react-native link react-native-gesture-handler react-native link react-native-screens @@ -99,7 +99,7 @@ Next, we need to link these libraries. The steps depends on your React Native ve Now, run the `postinstall` script manually: - ```sh + ```bash npm run postinstall ``` diff --git a/versioned_docs/version-4.x/troubleshooting.md b/versioned_docs/version-4.x/troubleshooting.md index a6a1db45087..edcd02182c5 100644 --- a/versioned_docs/version-4.x/troubleshooting.md +++ b/versioned_docs/version-4.x/troubleshooting.md @@ -19,13 +19,13 @@ If the module points to a local file (i.e. the name of the module starts with `. If you're using Expo, run: -```sh +```bash expo start -c ``` If you're not using Expo, run: -```sh +```bash npx react-native start --reset-cache ``` @@ -43,13 +43,13 @@ This and some similar errors might occur if you didn't link the [`react-native-g On newer versions of React Native, [linking is automatic](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md), so if you have linked the library manually, first unlink it: - ```sh + ```bash react-native unlink react-native-gesture-handler ``` If you're testing on iOS and use Mac, make sure you have run `pod install` in the `ios/` folder: - ```sh + ```bash cd ios; pod install; cd .. ``` @@ -57,7 +57,7 @@ This and some similar errors might occur if you didn't link the [`react-native-g If you're on an older React Native version, you need to manually link the library. To do that, run: - ```sh + ```bash react-native link react-native-gesture-handler ``` @@ -67,7 +67,7 @@ Now rebuild the app and test on your device or simulator. This error can often happen if you have a Babel plugin that compiles the code in a non-spec compliant way. For example: -```sh +```bash ["@babel/plugin-proposal-class-properties", { "loose": true}] ``` @@ -91,13 +91,13 @@ If you have additional options configured here, try removing them to see if it f If you're using Expo, run: -```sh +```bash expo start -c ``` If you're not using Expo, run: -```sh +```bash npx react-native start --reset-cache ``` diff --git a/versioned_docs/version-4.x/upgrading-from-3.x.md b/versioned_docs/version-4.x/upgrading-from-3.x.md index 6ac0a71cfa1..cea4e5dbd97 100644 --- a/versioned_docs/version-4.x/upgrading-from-3.x.md +++ b/versioned_docs/version-4.x/upgrading-from-3.x.md @@ -76,7 +76,7 @@ The latest drawer and tabs depend on [`react-native-gesture-handler`](https://gi In your project directory, run the following: -```sh +```bash npx expo install react-native-gesture-handler react-native-reanimated ``` @@ -94,7 +94,7 @@ Next, we need to link these libraries. The steps depends on your React Native ve To complete the linking on iOS, make sure you have [Cocoapods](https://cocoapods.org/) installed. Then run: - ```sh + ```bash cd ios pod install cd .. @@ -104,7 +104,7 @@ Next, we need to link these libraries. The steps depends on your React Native ve If you're on an older React Native version, you need to manually link the dependencies. To do that, run: - ```sh + ```bash react-native link react-native-reanimated react-native link react-native-gesture-handler ``` diff --git a/versioned_docs/version-5.x/configuring-links.md b/versioned_docs/version-5.x/configuring-links.md index 884b1270454..4542bece964 100644 --- a/versioned_docs/version-5.x/configuring-links.md +++ b/versioned_docs/version-5.x/configuring-links.md @@ -688,7 +688,7 @@ In the example app, you will use the Expo managed workflow. The guide will focus First, you need to decide the navigation structure of your app. To keep it simple, the main navigator will be bottom-tabs navigator with two screens. Its first screen will be a simple stack navigator, called `HomeStack`, with two screens: `Home` and `Profile`, and the second tabs screen will be just a simple one without any nested navigators, called `Settings`: -```sh +```bash BottomTabs ├── Stack (HomeStack) │   ├── Home diff --git a/versioned_docs/version-5.x/contributing.md b/versioned_docs/version-5.x/contributing.md index 391e337bf06..aa31a3cb0b6 100755 --- a/versioned_docs/version-5.x/contributing.md +++ b/versioned_docs/version-5.x/contributing.md @@ -111,7 +111,7 @@ Much like the issue template, the [pull request template](https://github.com/rea - Fork the [`repo`](https://github.com/react-navigation/react-navigation) on GitHub - Run these commands in the terminal to download locally and install it: -```sh +```bash git clone https://github.com//navigation-ex.git cd navigation-ex git remote add upstream https://github.com/react-navigation/react-navigation.git @@ -124,25 +124,25 @@ The project uses a monorepo structure for the packages managed by [yarn workspac Look around. Match the style of the rest of the codebase. This project uses ESLint to ensure consistency throughout the project. You can check your project by running: -```sh +```bash yarn lint ``` If any errors occur you'll either have to manually fix them or you can attempt to automatically fix them by running: -```sh +```bash yarn lint --fix ``` The codebase is written in TypeScript, and must pass typecheck. To typecheck files, run: -```sh +```bash yarn typescript ``` It's useful to run typechecking in watch mode when working on the project. To do it, run: -```sh +```bash yarn typescript --watch ``` @@ -152,7 +152,7 @@ The [example app](https://github.com/react-navigation/react-navigation/tree/main While developing, you can run the [example app](https://github.com/react-navigation/react-navigation/tree/main/example) with [Expo](https://expo.io/) to test your changes: -```sh +```bash yarn example start ``` @@ -160,13 +160,13 @@ yarn example start React Navigation has tests implemented in [Jest](https://facebook.github.io/jest/). To run either of these, from the React Navigation directory, run either of the following commands (after installing the `node_modules`) to run tests or type-checking. -```sh +```bash yarn test ``` It's useful to run tests in watch mode when working on the project. To do it, run: -```sh +```bash yarn test --watch ``` diff --git a/versioned_docs/version-5.x/deep-linking.md b/versioned_docs/version-5.x/deep-linking.md index f183ae2ff3a..d978f862b47 100755 --- a/versioned_docs/version-5.x/deep-linking.md +++ b/versioned_docs/version-5.x/deep-linking.md @@ -95,7 +95,7 @@ const linking = { To test the URI on the simulator in the Expo client app, run the following: -```sh +```bash npx uri-scheme open [ put your uri prefix in here] --ios # for example @@ -105,7 +105,7 @@ npx uri-scheme open exp://127.0.0.1:19000/--/chat/jan --ios or use `xcrun` directly: -```sh +```bash xcrun simctl openurl booted [ put your URI prefix in here ] # for example @@ -117,7 +117,7 @@ xcrun simctl openurl booted exp://127.0.0.1:19000/--/chat/jane To test the intent handling in the Expo client app on Android, run the following: -```sh +```bash npx uri-scheme open "[ put your URI prefix in here ]" --/chat/jan --android # for example @@ -127,7 +127,7 @@ npx uri-scheme open exp://127.0.0.1:19000/--/chat/jan --android or use `adb` directly: -```sh +```bash adb shell am start -W -a android.intent.action.VIEW -d "[ put your URI prefix in here ]" host.exp.exponent # for example @@ -200,19 +200,19 @@ If you want to do it manually, open the project at `SimpleApp/ios/SimpleApp.xcod Now you can press play in Xcode, or re-build on the command line: -```sh +```bash npx react-native run-ios ``` To test the URI on the simulator, run the following: -```sh +```bash npx uri-scheme open mychat://chat/jane --ios ``` or use `xcrun` directly: -```sh +```bash xcrun simctl openurl booted mychat://chat/jane ``` @@ -248,19 +248,19 @@ If you want to add it manually, open up `SimpleApp/android/app/src/main/AndroidM Now, re-install the app: -```sh +```bash react-native run-android ``` To test the intent handling in Android, run the following: -```sh +```bash npx uri-scheme open mychat://chat/jane --android ``` or use `adb` directly: -```sh +```bash adb shell am start -W -a android.intent.action.VIEW -d "mychat://chat/jane" com.simpleapp ``` diff --git a/versioned_docs/version-5.x/getting-started.md b/versioned_docs/version-5.x/getting-started.md index fe8737d1f0f..5cead6283ab 100755 --- a/versioned_docs/version-5.x/getting-started.md +++ b/versioned_docs/version-5.x/getting-started.md @@ -33,7 +33,7 @@ The libraries we will install now are [`react-native-gesture-handler`](https://g In your project directory, run: -```sh +```bash npx expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view ``` @@ -55,7 +55,7 @@ From React Native 0.60 and higher, [linking is automatic](https://github.com/rea 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. -```sh +```bash npx pod-install ios ``` diff --git a/versioned_docs/version-5.x/troubleshooting.md b/versioned_docs/version-5.x/troubleshooting.md index b331ca0a99a..79f26eb3432 100755 --- a/versioned_docs/version-5.x/troubleshooting.md +++ b/versioned_docs/version-5.x/troubleshooting.md @@ -18,19 +18,19 @@ If the module points to a local file (i.e. the name of the module starts with `. If you're using Expo, run: -```sh +```bash expo start -c ``` If you're not using Expo, run: -```sh +```bash npx react-native start --reset-cache ``` If that doesn't work, you can also try the following: -```sh +```bash rm -rf $TMPDIR/metro-bundler-cache-* ``` @@ -48,7 +48,7 @@ Sometimes it might even be due to a corrupt installation. If clearing cache didn Sometimes the error may look like this: -```sh +```bash Error: While trying to resolve module "@react-navigation/native" from file "/path/to/src/App.js", the package "/path/to/node_modules/@react-navigation/native/package.json" was successfully found. However, this package itself specifies a "main" module field that could not be resolved ("/path/to/node_modules/@react-navigation/native/src/index.tsx" ``` @@ -64,13 +64,13 @@ If it's missing these extensions, add them and then clear metro cache as shown i This might happen if you have an old version of the `metro-react-native-babel-preset` package. Try upgrading it to the latest version. -```sh npm2yarn +```bash npm2yarn npm install --save-dev metro-react-native-babel-preset ``` If you have `@babel/core` installed, also upgrade it to latest version. -```sh npm2yarn +```bash npm2yarn npm install --save-dev @babel/core ``` @@ -78,7 +78,7 @@ If upgrading the packages don't help, you can also try deleting your `node_modul If you use `npm`: -```sh +```bash rm -rf node_modules rm package-lock.json npm install @@ -86,7 +86,7 @@ npm install If you use `yarn`: -```sh +```bash rm -rf node_modules rm yarn.lock yarn @@ -98,7 +98,7 @@ After upgrading or reinstalling the packages, you should also clear Metro bundle This might happen if you have an old version of TypeScript in your project. You can try upgrading it: -```sh npm2yarn +```bash npm2yarn npm install --save-dev typescript ``` @@ -108,13 +108,13 @@ This and some similar errors might occur if you have a bare React Native project Linking is automatic from React Native 0.60, so if you have linked the library manually, first unlink it: -```sh +```bash react-native unlink react-native-gesture-handler ``` If you're testing on iOS and use Mac, make sure you have run `pod install` in the `ios/` folder: -```sh +```bash cd ios pod install cd .. @@ -128,13 +128,13 @@ This and some similar errors might occur if you have a bare React Native project Linking is automatic from React Native 0.60, so if you have linked the library manually, first unlink it: -```sh +```bash react-native unlink react-native-safe-area-context ``` If you're testing on iOS and use Mac, make sure you have run `pod install` in the `ios/` folder: -```sh +```bash cd ios pod install cd .. @@ -148,7 +148,7 @@ This might occur if you have multiple versions of [`react-native-safe-area-conte If you're using Expo managed workflow, it's likely that you have installed an incompatible version. To install the correct version, run: -```sh +```bash npx expo install react-native-safe-area-context ``` @@ -156,13 +156,13 @@ If it didn't fix the error or you're not using Expo managed workflow, you'll nee If you use `yarn`, run: -```sh +```bash yarn why react-native-safe-area-context ``` If you use `npm`, run: -```sh +```bash npm ls react-native-safe-area-context ``` @@ -180,13 +180,13 @@ If you use `yarn`, you can also temporarily override the version being installed And then run: -```sh +```bash yarn ``` If you're on iOS and not using Expo managed workflow, also run: -```sh +```bash cd ios pod install cd .. diff --git a/versioned_docs/version-6.x/configuring-links.md b/versioned_docs/version-6.x/configuring-links.md index 4040b1f00c2..d14718e3adb 100644 --- a/versioned_docs/version-6.x/configuring-links.md +++ b/versioned_docs/version-6.x/configuring-links.md @@ -726,7 +726,7 @@ In the example app, you will use the Expo managed workflow. The guide will focus First, you need to decide the navigation structure of your app. To keep it simple, the main navigator will be bottom-tabs navigator with two screens. Its first screen will be a simple stack navigator, called `HomeStack`, with two screens: `Home` and `Profile`, and the second tabs screen will be just a simple one without any nested navigators, called `Settings`: -```sh +```bash BottomTabs ├── Stack (HomeStack) │   ├── Home diff --git a/versioned_docs/version-6.x/contributing.md b/versioned_docs/version-6.x/contributing.md index 391e337bf06..aa31a3cb0b6 100755 --- a/versioned_docs/version-6.x/contributing.md +++ b/versioned_docs/version-6.x/contributing.md @@ -111,7 +111,7 @@ Much like the issue template, the [pull request template](https://github.com/rea - Fork the [`repo`](https://github.com/react-navigation/react-navigation) on GitHub - Run these commands in the terminal to download locally and install it: -```sh +```bash git clone https://github.com//navigation-ex.git cd navigation-ex git remote add upstream https://github.com/react-navigation/react-navigation.git @@ -124,25 +124,25 @@ The project uses a monorepo structure for the packages managed by [yarn workspac Look around. Match the style of the rest of the codebase. This project uses ESLint to ensure consistency throughout the project. You can check your project by running: -```sh +```bash yarn lint ``` If any errors occur you'll either have to manually fix them or you can attempt to automatically fix them by running: -```sh +```bash yarn lint --fix ``` The codebase is written in TypeScript, and must pass typecheck. To typecheck files, run: -```sh +```bash yarn typescript ``` It's useful to run typechecking in watch mode when working on the project. To do it, run: -```sh +```bash yarn typescript --watch ``` @@ -152,7 +152,7 @@ The [example app](https://github.com/react-navigation/react-navigation/tree/main While developing, you can run the [example app](https://github.com/react-navigation/react-navigation/tree/main/example) with [Expo](https://expo.io/) to test your changes: -```sh +```bash yarn example start ``` @@ -160,13 +160,13 @@ yarn example start React Navigation has tests implemented in [Jest](https://facebook.github.io/jest/). To run either of these, from the React Navigation directory, run either of the following commands (after installing the `node_modules`) to run tests or type-checking. -```sh +```bash yarn test ``` It's useful to run tests in watch mode when working on the project. To do it, run: -```sh +```bash yarn test --watch ``` diff --git a/versioned_docs/version-6.x/deep-linking.md b/versioned_docs/version-6.x/deep-linking.md index b9afa3cb2bc..6791958ceeb 100755 --- a/versioned_docs/version-6.x/deep-linking.md +++ b/versioned_docs/version-6.x/deep-linking.md @@ -29,7 +29,7 @@ First, you will want to specify a URL scheme for your app. This corresponds to t Next, install `expo-linking` which we'd need to get the deep link prefix: -```sh +```bash npx expo install expo-linking ``` @@ -103,7 +103,7 @@ Now you need to add the scheme to your project configuration. The easiest way to do this is with the `uri-scheme` package by running the following: -```sh +```bash npx uri-scheme add mychat --ios ``` @@ -193,13 +193,13 @@ Before testing deep links, make sure that you rebuild and install the app in you If you're testing on iOS, run: -```sh +```bash npx react-native run-ios ``` If you're testing on Android, run: -```sh +```bash npx react-native run-android ``` @@ -211,19 +211,19 @@ If you want to test with your custom scheme in your Expo app, you will need rebu The `uri-scheme` package is a command line tool that can be used to test deep links on both iOS & Android. It can be used as follows: -```sh +```bash npx uri-scheme open [your deep link] --[ios|android] ``` For example: -```sh +```bash npx uri-scheme open "mychat://chat/jane" --ios ``` Or if using Expo client: -```sh +```bash npx uri-scheme open "exp://127.0.0.1:19000/--/chat/jane" --ios ``` @@ -231,13 +231,13 @@ npx uri-scheme open "exp://127.0.0.1:19000/--/chat/jane" --ios The `xcrun` command can be used as follows to test deep links with the iOS simulator: -```sh +```bash xcrun simctl openurl booted [your deep link] ``` For example: -```sh +```bash xcrun simctl openurl booted "mychat://chat/jane" ``` @@ -245,19 +245,19 @@ xcrun simctl openurl booted "mychat://chat/jane" The `adb` command can be used as follows to test deep links with the Android emulator or a connected device: -```sh +```bash adb shell am start -W -a android.intent.action.VIEW -d [your deep link] [your android package name] ``` For example: -```sh +```bash adb shell am start -W -a android.intent.action.VIEW -d "mychat://chat/jane" com.simpleapp ``` Or if using Expo client: -```sh +```bash adb shell am start -W -a android.intent.action.VIEW -d "exp://127.0.0.1:19000/--/chat/jane" host.exp.exponent ``` diff --git a/versioned_docs/version-6.x/drawer-layout.md b/versioned_docs/version-6.x/drawer-layout.md new file mode 100644 index 00000000000..e05c774dcec --- /dev/null +++ b/versioned_docs/version-6.x/drawer-layout.md @@ -0,0 +1,267 @@ +--- +id: drawer-layout +title: React Native Drawer Layout +sidebar_label: Drawer Layout +--- + +A cross-platform Drawer component for React Native implemented using [`react-native-gesture-handler`](https://docs.swmansion.com/react-native-gesture-handler/) and [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/). + +
+ +
+ +This package doesn't integrate with React Navigation. If you want to integrate the drawer layout with React Navigation's navigation system, e.g. want to show screens in the drawer and be able to navigate between them using `navigation.navigate` etc, use [Drawer Navigator](drawer-navigator.md) instead. + +## Installation + +To use this package, open a Terminal in the project root and run: + +```bash npm2yarn +npm install react-native-drawer-layout +``` + +Then, you need to install and configure the libraries that are required by the drawer: + +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/). + + If you have a Expo managed project, in your project directory, run: + + ```bash + npx expo install react-native-gesture-handler react-native-reanimated + ``` + + If you have a bare React Native project, in your project directory, run: + + ```bash npm2yarn + npm install react-native-gesture-handler react-native-reanimated + ``` + + The Drawer supports both Reanimated 1 and Reanimated 2. If you want to use Reanimated 2, make sure to configure it following the [installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation). + +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`: + + ```js + import 'react-native-gesture-handler'; + ``` + + > 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. + +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 +``` + +We're done! Now you can build and run the app on your device/simulator. + +## Quick start + +```js +import * as React from 'react'; +import { Button, Text } from 'react-native'; +import { Drawer } from 'react-native-drawer-layout'; + +export default function DrawerExample() { + const [open, setOpen] = React.useState(false); + + return ( + setOpen(true)} + onClose={() => setOpen(false)} + renderDrawerContent={() => { + return Drawer content; + }} + > +