Skip to content

Commit 6860176

Browse files
authored
[docs] Extend docs for React Native DevTools (facebook#4410)
1 parent 5f22457 commit 6860176

File tree

8 files changed

+116
-22
lines changed

8 files changed

+116
-22
lines changed

docs/debugging.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ title: Debugging Basics
55

66
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants';
77

8+
:::note
9+
Debugging features, such as the Dev Menu, LogBox, and React Native DevTools are disabled in release (production) builds.
10+
:::
11+
812
## Opening the Dev Menu
913

10-
React Native provides an in-app developer menu which offers several debugging options. You can access the Dev Menu by shaking your device or via keyboard shortcuts:
14+
React Native provides an in-app developer menu providing access to debugging features. You can access the Dev Menu by shaking your device or via keyboard shortcuts:
1115

1216
- iOS Simulator: <kbd>Ctrl</kbd> + <kbd>Cmd ⌘</kbd> + <kbd>Z</kbd> (or Device > Shake)
1317
- Android emulators: <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (macOS) or <kbd>Ctrl</kbd> + <kbd>M</kbd> (Windows and Linux)
1418

15-
Alternatively for Android devices and emulators, you can run `adb shell input keyevent 82` in your terminal.
19+
Alternative (Android): `adb shell input keyevent 82`.
1620

1721
![The React Native Dev Menu](/docs/assets/debugging-dev-menu-076.jpg)
1822

19-
:::note
20-
The Dev Menu is disabled in release (production) builds.
21-
:::
22-
2323
## Opening DevTools
2424

2525
[React Native DevTools](./react-native-devtools) is our built-in debugger for React Native. It allows you to inspect and understand how your JavaScript code is running, similar to a web browser.
@@ -63,10 +63,6 @@ LogBox is an in-app tool that displays when warnings or errors are logged by you
6363

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

66-
:::note
67-
LogBox is disabled in release (production) builds.
68-
:::
69-
7066
### Fatal Errors
7167

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

docs/react-native-devtools.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: React Native DevTools
55

66
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants';
77

8-
React Native DevTools is our new debugging experience featuring an end-to-end rewrite of our debugger stack. It aims to be more deeply integrated and fundamentally more reliable than previous debugging methods in React Native.
8+
React Native DevTools is our modern debugging experience for React Native. Purpose-built from the ground up, it aims to be fundamentally more integrated, correct, and reliable than previous debugging methods.
99

1010
![React Native DevTools opened to the "Welcome" pane](/docs/assets/debugging-rndt-welcome.jpg)
1111

@@ -79,6 +79,57 @@ Breakpoints are a fundamental tool in your debugging toolkit!
7979
- Use a `debugger;` statement to quickly set a breakpoint from your text editor. This will reach the device immediately via Fast Refresh.
8080
- There are multiple kinds of breakpoints! For example, [Conditional Breakpoints and Logpoints](https://developer.chrome.com/docs/devtools/javascript/breakpoints#overview).
8181

82+
### Memory
83+
84+
![Inspecting a heap snapshot in the Memory panel](/docs/assets/debugging-rndt-memory.jpg)
85+
86+
The Memory panel allows you to take a heap snapshot and view the memory usage of your JavaScript code over time.
87+
88+
[Record heap snapshots | Chrome DevTools](https://developer.chrome.com/docs/devtools/memory-problems/heap-snapshots)
89+
90+
#### Useful tips
91+
92+
- Use <kbd>Cmd ⌘</kbd>+<kbd>F</kbd> / <kbd>Ctrl</kbd>+<kbd>F</kbd> to filter for specific objects in the heap.
93+
- Taking an [allocation timeline report](https://developer.chrome.com/docs/devtools/memory-problems/allocation-profiler) can be useful to see memory usage over time as a graph, to identify possible memory leaks.
94+
95+
## React DevTools features
96+
97+
In the integrated Components and Profiler panels, you'll find all the features of the [React DevTools](https://react.dev/learn/react-developer-tools) browser extension. These work seamlessly in React Native DevTools.
98+
99+
### React Components
100+
101+
![Selecting and locating elements using the React Components panel](/docs/assets/debugging-rndt-react-components.gif)
102+
103+
The React Components panel allows you to inspect and update the rendered React component tree.
104+
105+
- Hover or select an element in DevTools to highlight it on device.
106+
- To locate an element in DevTools, click the top-left "Select element" button, then tap any element in the app.
107+
108+
#### Useful tips
109+
110+
- Props and state on a component can be viewed and modified at runtime using the right hand panel.
111+
- Components optimized with [React Compiler](https://react.dev/learn/react-compiler) will be annotated with a "Memo ✨" badge.
112+
113+
:::tip
114+
115+
#### Protip: Highlight re-renders
116+
117+
Re-renders can be a significant contributor to performance issues in React apps. DevTools can highlight component re-renders as they happen.
118+
119+
- To enable, click the View Settings (`⚙︎`) icon and check "Highlight updates when components render".
120+
121+
![Location of the "highlight updates" setting, next to a recording of the live render overlay](/docs/assets/debugging-rndt-highlight-renders.gif)
122+
123+
:::
124+
125+
### React Profiler
126+
127+
![A profile rendered as a flame graph](/docs/assets/debugging-rndt-react-profiler.jpg)
128+
129+
The React Profiler panel allows you to record performance profiles to understand the timing of component renders and React commits.
130+
131+
For more info, see the [original 2018 guide](https://legacy.reactjs.org/blog/2018/09/10/introducing-the-react-profiler.html#reading-performance-data) (note that parts of this may be outdated).
132+
82133
## Reconnecting DevTools
83134

84135
Occasionally, DevTools might disconnect from the target device. This can happen if:
4.22 MB
Loading
384 KB
Loading
1.94 MB
Loading
394 KB
Loading

website/versioned_docs/version-0.76/debugging.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ title: Debugging Basics
55

66
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants';
77

8+
:::note
9+
Debugging features, such as the Dev Menu, LogBox, and React Native DevTools are disabled in release (production) builds.
10+
:::
11+
812
## Opening the Dev Menu
913

10-
React Native provides an in-app developer menu which offers several debugging options. You can access the Dev Menu by shaking your device or via keyboard shortcuts:
14+
React Native provides an in-app developer menu providing access to debugging features. You can access the Dev Menu by shaking your device or via keyboard shortcuts:
1115

12-
- iOS Simulator: <kbd>Cmd ⌘</kbd> + <kbd>D</kbd> (or Device > Shake)
16+
- iOS Simulator: <kbd>Ctrl</kbd> + <kbd>Cmd ⌘</kbd> + <kbd>Z</kbd> (or Device > Shake)
1317
- Android emulators: <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (macOS) or <kbd>Ctrl</kbd> + <kbd>M</kbd> (Windows and Linux)
1418

15-
Alternatively for Android devices and emulators, you can run `adb shell input keyevent 82` in your terminal.
19+
Alternative (Android): `adb shell input keyevent 82`.
1620

1721
![The React Native Dev Menu](/docs/assets/debugging-dev-menu-076.jpg)
1822

19-
:::note
20-
The Dev Menu is disabled in release (production) builds.
21-
:::
22-
2323
## Opening DevTools
2424

2525
[React Native DevTools](./react-native-devtools) is our built-in debugger for React Native. It allows you to inspect and understand how your JavaScript code is running, similar to a web browser.
@@ -63,10 +63,6 @@ LogBox is an in-app tool that displays when warnings or errors are logged by you
6363

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

66-
:::note
67-
LogBox is disabled in release (production) builds.
68-
:::
69-
7066
### Fatal Errors
7167

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

website/versioned_docs/version-0.76/react-native-devtools.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,57 @@ Breakpoints are a fundamental tool in your debugging toolkit!
7979
- Use a `debugger;` statement to quickly set a breakpoint from your text editor. This will reach the device immediately via Fast Refresh.
8080
- There are multiple kinds of breakpoints! For example, [Conditional Breakpoints and Logpoints](https://developer.chrome.com/docs/devtools/javascript/breakpoints#overview).
8181

82+
### Memory
83+
84+
![Inspecting a heap snapshot in the Memory panel](/docs/assets/debugging-rndt-memory.jpg)
85+
86+
The Memory panel allows you to take a heap snapshot and view the memory usage of your JavaScript code over time.
87+
88+
[Record heap snapshots | Chrome DevTools](https://developer.chrome.com/docs/devtools/memory-problems/heap-snapshots)
89+
90+
#### Useful tips
91+
92+
- Use <kbd>Cmd ⌘</kbd>+<kbd>F</kbd> / <kbd>Ctrl</kbd>+<kbd>F</kbd> to filter for specific objects in the heap.
93+
- Taking an [allocation timeline report](https://developer.chrome.com/docs/devtools/memory-problems/allocation-profiler) can be useful to see memory usage over time as a graph, to identify possible memory leaks.
94+
95+
## React DevTools features
96+
97+
In the integrated Components and Profiler panels, you'll find all the features of the [React DevTools](https://react.dev/learn/react-developer-tools) browser extension. These work seamlessly in React Native DevTools.
98+
99+
### React Components
100+
101+
![Selecting and locating elements using the React Components panel](/docs/assets/debugging-rndt-react-components.gif)
102+
103+
The React Components panel allows you to inspect and update the rendered React component tree.
104+
105+
- Hover or select an element in DevTools to highlight it on device.
106+
- To locate an element in DevTools, click the top-left "Select element" button, then tap any element in the app.
107+
108+
#### Useful tips
109+
110+
- Props and state on a component can be viewed and modified at runtime using the right hand panel.
111+
- Components optimized with [React Compiler](https://react.dev/learn/react-compiler) will be annotated with a "Memo ✨" badge.
112+
113+
:::tip
114+
115+
#### Protip: Highlight re-renders
116+
117+
Re-renders can be a significant contributor to performance issues in React apps. DevTools can highlight component re-renders as they happen.
118+
119+
- To enable, click the View Settings (`⚙︎`) icon and check "Highlight updates when components render".
120+
121+
![Location of the "highlight updates" setting, next to a recording of the live render overlay](/docs/assets/debugging-rndt-highlight-renders.gif)
122+
123+
:::
124+
125+
### React Profiler
126+
127+
![A profile rendered as a flame graph](/docs/assets/debugging-rndt-react-profiler.jpg)
128+
129+
The React Profiler panel allows you to record performance profiles to understand the timing of component renders and React commits.
130+
131+
For more info, see the [original 2018 guide](https://legacy.reactjs.org/blog/2018/09/10/introducing-the-react-profiler.html#reading-performance-data) (note that parts of this may be outdated).
132+
82133
## Reconnecting DevTools
83134

84135
Occasionally, DevTools might disconnect from the target device. This can happen if:

0 commit comments

Comments
 (0)