|
| 1 | +--- |
| 2 | +id: troubleshooting |
| 3 | +title: Troubleshooting |
| 4 | +sidebar_label: Troubleshooting |
| 5 | +--- |
| 6 | + |
| 7 | +This section points out issues not directly connected with React Navigation but which may occur while using it. |
| 8 | + |
| 9 | +## I'm getting an error "Unable to resolve module" after updating to the latest version |
| 10 | + |
| 11 | +This might happen for 2 reasons: |
| 12 | + |
| 13 | +- Incorrect cache of Metro bundler |
| 14 | +- Missing peer dependency |
| 15 | + |
| 16 | +If the module points to a local file (i.e. the name of the module starts with `./`), then it's probably due to incorrect cache. To fix this, try the following solutions. |
| 17 | + |
| 18 | +If you're using Expo, run: |
| 19 | + |
| 20 | +```sh |
| 21 | +expo start -c |
| 22 | +``` |
| 23 | + |
| 24 | +If you're not using Expo, run: |
| 25 | + |
| 26 | +```sh |
| 27 | +react-native start --reset-cache |
| 28 | +``` |
| 29 | + |
| 30 | +If the module points to an npm package (i.e. the name of the module doesn't with `./`), then it's probably due to a missing peer dependency. To fix this, install the dependency in your project: |
| 31 | + |
| 32 | +```sh |
| 33 | +yarn add name-of-the-module |
| 34 | +``` |
| 35 | + |
| 36 | +## I'm getting an error "null is not an object ( evaluating 'RNGestureHandlerModule.default.Direction')". |
| 37 | + |
| 38 | +This and some similar errors might occur if you didn't link the RNGestureHandler library. |
| 39 | + |
| 40 | +To fix it, run this command in your project directory: |
| 41 | + |
| 42 | +```sh |
| 43 | +react-native link react-native-gesture-handler |
| 44 | +``` |
| 45 | + |
| 46 | +## I linked RNGestureHandler library but gestures won't work on Android. |
| 47 | + |
| 48 | +This might happen if you didn't update your MainActivity.java file (or wherever you create an instance of ReactActivityDelegate), so that it uses the root view wrapper provided by this library. |
| 49 | + |
| 50 | +Check how to do it [here](https://software-mansion.github.io/react-native-gesture-handler/docs/getting-started.html). |
| 51 | + |
| 52 | +# Common mistakes |
| 53 | + |
| 54 | +This section attempts to outline issues that users frequently encounter when first getting accustomed to using React Navigation and serves as a reference in some cases for error messages. |
| 55 | + |
| 56 | +## Wrapping AppContainer in a View without flex |
| 57 | + |
| 58 | +If you wrap the `AppContainer` in a `View`, make sure the `View` is using flex. |
| 59 | + |
| 60 | +```js |
| 61 | +import * as React from 'react'; |
| 62 | +import { NavigationNativeContainer } from '@react-navigation/native'; |
| 63 | + |
| 64 | +// without the style you will see a blank screen |
| 65 | +export default () => ( |
| 66 | + <View style={{ flex: 1 }}> |
| 67 | + <NavigationNativeContainer>{/* ... */}</NavigationNativeContainer> |
| 68 | + </View> |
| 69 | +); |
| 70 | +``` |
0 commit comments