Skip to content

Commit 6cb6a19

Browse files
authored
[docs] Update LogBox guide for RNDT, disambiguate ignore/filter behaviour (#4245)
1 parent dd27a86 commit 6cb6a19

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed

docs/debugging.md

+35-13
Original file line numberDiff line numberDiff line change
@@ -110,43 +110,65 @@ npx react-devtools
110110

111111
## LogBox
112112

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.
114114

115-
![A LogBox warning and an expanded LogBox syntax error](/docs/assets/debugging-logbox.jpg)
115+
![A LogBox warning and an expanded LogBox syntax error](/docs/assets/debugging-logbox-076.jpg)
116116

117117
:::note
118118
LogBox is disabled in release (production) builds.
119119
:::
120120

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+
121125
### Console Errors and Warnings
122126

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.
124128

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.
126131

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.
130138

131139
```js
132140
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
133152

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
135156
LogBox.ignoreLogs([
136157
// Exact message
137158
'Warning: componentWillReceiveProps has been renamed',
138159

139160
// Substring or regex match
140161
/GraphQL error: .*/,
141162
]);
142-
143-
// Ignore all log notifications
144-
LogBox.ignoreAllLogs();
145163
```
146164

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+
:::
148170

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.
171+
</details>
150172

151173
## Performance Monitor
152174

Loading

0 commit comments

Comments
 (0)