Skip to content

Commit 08c8b20

Browse files
committed
[docs] Refresh React DevTools visuals
1 parent 60a4da2 commit 08c8b20

File tree

5 files changed

+36
-15
lines changed

5 files changed

+36
-15
lines changed

docs/react-devtools.md

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,26 @@ title: React DevTools
55

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

8-
You can use [the standalone version of React Developer Tools](https://github.com/facebook/react/tree/main/packages/react-devtools) to debug the React component hierarchy. To use it, install the `react-devtools` package globally:
8+
[React DevTools](https://github.com/facebook/react/tree/main/packages/react-devtools) can be used to debug the React component hierarchy within your app.
9+
10+
The standalone version of React DevTools allows connecting to React Native apps. To use it, install or run the `react-devtools` package. It should connect to your simulator within a few seconds.
11+
12+
```sh
13+
npx react-devtools
14+
```
15+
16+
![The React DevTools interface](/docs/assets/debugging-react-devtools-detail.jpg)
17+
18+
19+
<details>
20+
<summary>💡 Installing React DevTools globally</summary>
21+
22+
We recommend running `react-devtools` via `npx`, but you can also install a given version globally.
923

1024
<Tabs groupId="package-manager" defaultValue={constants.defaultPackageManager} values={constants.packageManagers}>
1125
<TabItem value="npm">
1226

13-
```shell
27+
```sh
1428
npm install -g react-devtools
1529
```
1630

@@ -24,29 +38,36 @@ yarn global add react-devtools
2438
</TabItem>
2539
</Tabs>
2640

27-
Now run `react-devtools` from the terminal to launch the standalone DevTools app. It should connect to your simulator within a few seconds.
41+
Then, run the global `react-devtools` command:
2842

29-
```shell
43+
```sh
3044
react-devtools
3145
```
3246

33-
![React DevTools](/docs/assets/ReactDevTools.png)
47+
</details>
48+
49+
<details>
50+
<summary>💡 Adding React DevTools as a project dependency</summary>
3451

35-
:::info
3652
If you prefer to avoid global installations, you can add `react-devtools` as a project dependency. Add the `react-devtools` package to your project using `npm install --save-dev react-devtools`, then add `"react-devtools": "react-devtools"` to the `scripts` section in your `package.json`, and then run `npm run react-devtools` from your project folder to open the DevTools.
53+
54+
</details>
55+
56+
:::tip
57+
Learn more about using DevTools in the [React Developer Tools guide on react.dev](https://react.dev/learn/react-developer-tools).
3758
:::
3859

39-
## Integration with React Native Inspector
60+
## Integration with the Element Inspector
4061

41-
Open the Dev Menu and choose "Toggle Inspector". It will bring up an overlay that lets you tap on any UI element and see information about it:
62+
React Native provides an Element Inspector, available under the Dev Menu as "Show Element Inspector". The inspector lets you tap on any UI element and see information about it.
4263

43-
![React Native Inspector](/docs/assets/Inspector.gif)
64+
![Video of the Element Inspector interface](/docs/assets/debugging-element-inspector.gif)
4465

45-
However, when `react-devtools` is running, Inspector will enter a collapsed mode, and instead use the DevTools as primary UI. In this mode, clicking on something in the simulator will bring up the relevant components in the DevTools:
66+
When React DevTools is connected, the Element Inspector will enter a **collapsed mode**, and instead use DevTools as the primary UI. In this mode, clicking on something in the simulator will navigate to the relevant component in DevTools.
4667

47-
![React DevTools Inspector Integration](/docs/assets/ReactDevToolsInspector.gif)
68+
You can select "Hide Element Inspector" in the same menu to exit this mode.
4869

49-
You can choose "Toggle Inspector" in the same menu to exit this mode.
70+
![React DevTools Element Inspector integration](/docs/assets/debugging-element-inspector-react-devtools.gif)
5071

5172
## Debugging application state
5273

@@ -57,11 +78,11 @@ You can view installation instructions [in the README](https://github.com/infini
5778
## Troubleshooting
5879

5980
:::tip
60-
Once you have React DevTools running, follow the instructions. If you had your application running prior to opening React DevTools, you may need to [open developer menu](/docs/debugging#accessing-the-dev-menu) to connect them.
81+
Once you have React DevTools running, follow the instructions. If you had your application running prior to opening React DevTools, you may need to [open the Dev Menu](./debugging#accessing-the-dev-menu) to connect it.
6182

62-
![React DevTools Connection](/docs/assets/ReactDevToolsConnection.gif)
83+
![React DevTools connection flow](/docs/assets/debugging-react-devtools-connection.gif)
6384
:::
6485

6586
:::info
66-
If connecting to the emulator proves troublesome (especially Android 12), try running `adb reverse tcp:8097 tcp:8097` in a new terminal.
87+
If connecting to an Android emulator proves troublesome, try running `adb reverse tcp:8097 tcp:8097` in a new terminal.
6788
:::
1.55 MB
Loading
2.73 MB
Loading
1.24 MB
Loading
140 KB
Loading

0 commit comments

Comments
 (0)