Explain how to use React Developer Tools
Summary: Existing instructions are a bit misleading, as Chrome extension is not supposed to work, but there is still a supported way to run them. Closes https://github.com/facebook/react-native/pull/13707 Differential Revision: D5010169 Pulled By: gaearon fbshipit-source-id: f9558c9ccb04196854b2eef6ff40a998350b65db
This commit is contained in:
parent
d24305e4b1
commit
863e66e449
|
@ -63,6 +63,8 @@ To debug the JavaScript code in Chrome, select "Debug JS Remotely" from the Deve
|
||||||
|
|
||||||
Select `Tools → Developer Tools` from the Chrome Menu to open the [Developer Tools](https://developer.chrome.com/devtools). You may also access the DevTools using keyboard shortcuts (**`Command`**`⌘` + **`Option`**`⌥` + **`I`** on Mac, **`Ctrl`** + **`Shift`** + **`I`** on Windows). You may also want to enable [Pause On Caught Exceptions](http://stackoverflow.com/questions/2233339/javascript-is-there-a-way-to-get-chrome-to-break-on-all-errors/17324511#17324511) for a better debugging experience.
|
Select `Tools → Developer Tools` from the Chrome Menu to open the [Developer Tools](https://developer.chrome.com/devtools). You may also access the DevTools using keyboard shortcuts (**`Command`**`⌘` + **`Option`**`⌥` + **`I`** on Mac, **`Ctrl`** + **`Shift`** + **`I`** on Windows). You may also want to enable [Pause On Caught Exceptions](http://stackoverflow.com/questions/2233339/javascript-is-there-a-way-to-get-chrome-to-break-on-all-errors/17324511#17324511) for a better debugging experience.
|
||||||
|
|
||||||
|
> Note: the React Developer Tools Chrome extension does not work with React Native, but you can use its standalone version instead. Read the [next section](#react-developer-tools) to learn how.
|
||||||
|
|
||||||
### Debugging using a custom JavaScript debugger
|
### Debugging using a custom JavaScript debugger
|
||||||
|
|
||||||
To use a custom JavaScript debugger in place of Chrome Developer Tools, set the `REACT_DEBUGGER` environment variable to a command that will start your custom debugger. You can then select "Debug JS Remotely" from the Developer Menu to start debugging.
|
To use a custom JavaScript debugger in place of Chrome Developer Tools, set the `REACT_DEBUGGER` environment variable to a command that will start your custom debugger. You can then select "Debug JS Remotely" from the Developer Menu to start debugging.
|
||||||
|
@ -71,6 +73,38 @@ The debugger will receive a list of all project roots, separated by a space. For
|
||||||
|
|
||||||
> Custom debugger commands executed this way should be short-lived processes, and they shouldn't produce more than 200 kilobytes of output.
|
> Custom debugger commands executed this way should be short-lived processes, and they shouldn't produce more than 200 kilobytes of output.
|
||||||
|
|
||||||
|
## React Developer Tools
|
||||||
|
|
||||||
|
With React Native 0.43 or higher, you can use [the standalone version of React Developer Tools](https://github.com/facebook/react-devtools/tree/master/packages/react-devtools) to debug the React component hierarchy. To use it, install the `react-devtools` package globally:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install -g react-devtools
|
||||||
|
```
|
||||||
|
|
||||||
|
Now run `react-devtools` from the terminal to launch the standalone DevTools app:
|
||||||
|
|
||||||
|
```
|
||||||
|
react-devtools
|
||||||
|
```
|
||||||
|
|
||||||
|
<img src="https://camo.githubusercontent.com/3226d81c8d40f07f10c1f78876905a1bfc2d6d82/687474703a2f2f692e696d6775722e636f6d2f49586548695a442e706e67" width="700" alt="React DevTools">
|
||||||
|
|
||||||
|
It should connect to your simulator within a few seconds.
|
||||||
|
|
||||||
|
> Note: if you prefer to avoid global installations, you can add `react-devtools` as a project dependency. With Yarn, you can run `yarn add --dev react-devtools`, and then run `yarn react-devtools` from your project folder to open the DevTools. With npm, you can run `npm install --save-dev react-devtools`, 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.
|
||||||
|
|
||||||
|
### Integration with React Native Inspector
|
||||||
|
|
||||||
|
You can open the [in-app developer menu](#accessing-the-in-app-developer-menu) and choose "Show Inspector". It will bring up an overlay that lets you tap on any UI element and see information about it:
|
||||||
|
|
||||||
|
<img src="https://d2ppvlu71ri8gs.cloudfront.net/items/1R1d2x0O3M0C1t071Q0F/Screen%20Recording%202017-05-01%20at%2020.14.gif?v=45691135" alt="Show Inspector" width="300">
|
||||||
|
|
||||||
|
However, when `react-devtools` is running, Inspector will enter a special 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:
|
||||||
|
|
||||||
|
<img src="https://d2ppvlu71ri8gs.cloudfront.net/items/1v031W3O1W322z3G1k15/Screen%20Recording%202017-05-01%20at%2020.16.gif?v=a87eb3f4" alt="Show Inspector with React DevTools" width="700">
|
||||||
|
|
||||||
|
You can choose "Hide Inspector" in the same menu to exit this mode.
|
||||||
|
|
||||||
## Performance Monitor
|
## Performance Monitor
|
||||||
|
|
||||||
You can enable a performance overlay to help you debug performance problems by selecting "Perf Monitor" in the Developer Menu.
|
You can enable a performance overlay to help you debug performance problems by selecting "Perf Monitor" in the Developer Menu.
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue