You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/debugging.md
+35-13
Original file line number
Diff line number
Diff line change
@@ -110,43 +110,65 @@ npx react-devtools
110
110
111
111
## LogBox
112
112
113
-
Errors and warnings in development builds are displayed in LogBox inside your app.
113
+
LogBox is an in-app tool that displays when warnings or errors are logged by your app.
114
114
115
-

115
+

116
116
117
117
:::note
118
118
LogBox is disabled in release (production) builds.
119
119
:::
120
120
121
+
### Fatal Errors
122
+
123
+
When an unrecoverable error occurs, such as a JavaScript syntax error, LogBox will open with the location of the error. In this state, LogBox is not dismissable since your code cannot be executed. LogBox will automatically dismiss once the syntax error is fixed — either via Fast Refresh or after a manual reload.
124
+
121
125
### Console Errors and Warnings
122
126
123
-
Console errors and warnings are displayed as on-screen notifications with a red or yellow badge, and a notification count. To see more about an error or warning, tap the notification to see an expanded view and to paginate through other logs.
127
+
Console errors and warnings are displayed as on-screen notifications with a red or yellow badge.
124
128
125
-
LogBox notifications can be disabled using `LogBox.ignoreAllLogs()`. This can be useful when giving product demos, for example. Additionally, notifications can be disabled on a per-log basis via `LogBox.ignoreLogs()`. This can be useful for noisy warnings or those that cannot be fixed, e.g. in a third-party dependency.
129
+
-**Errors** will display with a notification count. Tap the notification to see an expanded view and to paginate through other logs.
130
+
-**Warnings** will display a notification banner without details, prompting you to open React Native DevTools.
126
131
127
-
:::info
128
-
Ignore logs as a last resort and create a task to fix any logs that are ignored.
129
-
:::
132
+
When React Native DevTools is open, all errors except fatal errors will be hidden to LogBox. We recommend using the Console panel within React Native DevTools as a source of truth, due to various LogBox options which can hide or adjust the level of certain logs.
133
+
134
+
<details>
135
+
<summary>**💡 Ignoring logs**</summary>
136
+
137
+
LogBox can be configured via the `LogBox` API.
130
138
131
139
```js
132
140
import {LogBox} from'react-native';
141
+
```
142
+
143
+
#### Ignore all logs
144
+
145
+
LogBox notifications can be disabled using `LogBox.ignoreAllLogs()`. This can be useful in situations such as giving product demos.
146
+
147
+
```js
148
+
LogBox.ignoreAllLogs();
149
+
```
150
+
151
+
#### Ignore specific logs
133
152
134
-
// Ignore log notification by message
153
+
Notifications can be disabled on a per-log basis via `LogBox.ignoreLogs()`. This can be useful for noisy warnings or those that cannot be fixed, e.g. in a third-party dependency.
154
+
155
+
```js
135
156
LogBox.ignoreLogs([
136
157
// Exact message
137
158
'Warning: componentWillReceiveProps has been renamed',
138
159
139
160
// Substring or regex match
140
161
/GraphQL error: .*/,
141
162
]);
142
-
143
-
// Ignore all log notifications
144
-
LogBox.ignoreAllLogs();
145
163
```
146
164
147
-
### Syntax Errors
165
+
:::note
166
+
167
+
LogBox will treat certain errors from React as warnings, which will mean they don't display as an in-app error notification. Advanced users can change this behaviour by customising LogBox's warning filter using [`LogBoxData.setWarningFilter()`](https://github.com/facebook/react-native/blob/d334f4d77eea538dff87fdcf2ebc090246cfdbb0/packages/react-native/Libraries/LogBox/Data/LogBoxData.js#L338).
168
+
169
+
:::
148
170
149
-
When a JavaScript syntax error occurs, LogBox will open with the location of the error. In this state, LogBox is not dismissable since your code cannot be executed. LogBox will automatically dismiss once the syntax error is fixed — either via Fast Refresh or after a manual reload.
0 commit comments