Skip to content

Commit 5e9ad5e

Browse files
authored
change Common mistakes to TroubleShooting and add examples (#606)
* add first look on troubleshooting section * rename common mistakes to troubleshooting
1 parent 7fe33f5 commit 5e9ad5e

File tree

4 files changed

+76
-32
lines changed

4 files changed

+76
-32
lines changed

docs/common-mistakes.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

docs/troubleshooting.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
```

website/i18n/en.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
"title": "createBottomTabNavigator",
2222
"sidebar_label": "createBottomTabNavigator"
2323
},
24-
"common-mistakes": {
25-
"title": "Common mistakes",
26-
"sidebar_label": "Common mistakes"
27-
},
2824
"community-libraries-and-navigators": {
2925
"title": "Community-developed Navigators and Libraries",
3026
"sidebar_label": "Community Navigators and Libraries"
@@ -253,6 +249,10 @@
253249
"title": "Themes",
254250
"sidebar_label": "Themes"
255251
},
252+
"troubleshooting": {
253+
"title": "Troubleshooting",
254+
"sidebar_label": "Troubleshooting"
255+
},
256256
"typescript": {
257257
"title": "Type checking with TypeScript",
258258
"sidebar_label": "Type checking with TypeScript"

website/sidebars.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"next-steps",
1515
"glossary-of-terms",
1616
"compatibility",
17-
"common-mistakes",
17+
"troubleshooting",
1818
"limitations"
1919
],
2020
"Guides": [
@@ -78,10 +78,7 @@
7878
]
7979
}
8080
],
81-
"Build your own Navigator": [
82-
"custom-routers",
83-
"custom-navigators"
84-
],
81+
"Build your own Navigator": ["custom-routers", "custom-navigators"],
8582
"Additional Resources": [
8683
"supported-react-native-versions",
8784
"community-libraries-and-navigators",

0 commit comments

Comments
 (0)