diff --git a/docs/react-devtools.md b/docs/react-devtools.md index 1ce0c7bec13..ced5c6589a2 100644 --- a/docs/react-devtools.md +++ b/docs/react-devtools.md @@ -5,12 +5,25 @@ title: React DevTools import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants'; -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: +[React DevTools](https://github.com/facebook/react/tree/main/packages/react-devtools) can be used to debug the React component hierarchy within your app. + +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. + +```sh +npx react-devtools +``` + +![The React DevTools interface](/docs/assets/debugging-react-devtools-detail.jpg) + +
+💡 Installing React DevTools globally + +We recommend running `react-devtools` via `npx`, but you can also install a given version globally. -```shell +```sh npm install -g react-devtools ``` @@ -24,29 +37,36 @@ yarn global add react-devtools -Now run `react-devtools` from the terminal to launch the standalone DevTools app. It should connect to your simulator within a few seconds. +Then, run the global `react-devtools` command: -```shell +```sh react-devtools ``` -![React DevTools](/docs/assets/ReactDevTools.png) +
+ +
+💡 Adding React DevTools as a project dependency -:::info 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. + +
+ +:::tip +Learn more about using DevTools in the [React Developer Tools guide on react.dev](https://react.dev/learn/react-developer-tools). ::: -## Integration with React Native Inspector +## Integration with the Element Inspector -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: +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. -![React Native Inspector](/docs/assets/Inspector.gif) +![Video of the Element Inspector interface](/docs/assets/debugging-element-inspector.gif) -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: +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. -![React DevTools Inspector Integration](/docs/assets/ReactDevToolsInspector.gif) +You can select "Hide Element Inspector" in the same menu to exit this mode. -You can choose "Toggle Inspector" in the same menu to exit this mode. +![React DevTools Element Inspector integration](/docs/assets/debugging-element-inspector-react-devtools.gif) ## Debugging application state @@ -57,11 +77,11 @@ You can view installation instructions [in the README](https://github.com/infini ## Troubleshooting :::tip -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. +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. -![React DevTools Connection](/docs/assets/ReactDevToolsConnection.gif) +![React DevTools connection flow](/docs/assets/debugging-react-devtools-connection.gif) ::: :::info -If connecting to the emulator proves troublesome (especially Android 12), try running `adb reverse tcp:8097 tcp:8097` in a new terminal. +If connecting to an Android emulator proves troublesome, try running `adb reverse tcp:8097 tcp:8097` in a new terminal. ::: diff --git a/website/static/docs/assets/debugging-element-inspector-react-devtools.gif b/website/static/docs/assets/debugging-element-inspector-react-devtools.gif new file mode 100644 index 00000000000..666dfc62b61 Binary files /dev/null and b/website/static/docs/assets/debugging-element-inspector-react-devtools.gif differ diff --git a/website/static/docs/assets/debugging-element-inspector.gif b/website/static/docs/assets/debugging-element-inspector.gif new file mode 100644 index 00000000000..86939626c86 Binary files /dev/null and b/website/static/docs/assets/debugging-element-inspector.gif differ diff --git a/website/static/docs/assets/debugging-react-devtools-connection.gif b/website/static/docs/assets/debugging-react-devtools-connection.gif new file mode 100644 index 00000000000..031fc58cbbb Binary files /dev/null and b/website/static/docs/assets/debugging-react-devtools-connection.gif differ diff --git a/website/static/docs/assets/debugging-react-devtools-detail.jpg b/website/static/docs/assets/debugging-react-devtools-detail.jpg new file mode 100644 index 00000000000..98bbc91b158 Binary files /dev/null and b/website/static/docs/assets/debugging-react-devtools-detail.jpg differ