React developer tools

React provides the tools for developers to debug React code. It allows us to inspect a React-rendered component with the component hierarchy, props, and state.

Installation

There are two official extensions that are available for the Chrome and Firefox browsers.

Download the extension for Chrome:

https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en

And Firefox:

https://addons.mozilla.org/en-US/firefox/addon/react-devtools/

Note

A standalone app is still under development and will be available soon.

How to use

Once you download or install the extension in your browser, open the Developer Tools on a React page. You should see one extra tab called React:

How to use

In the side panel, you can see the State and Props for every React component. If you expand the State of the component, you will see the full hierarchy of the component with the name of the component you are using in the React app.

See the following screenshot:

How to use

Right-click on the side panel and we can inspect and edit its current props and state in the panel on the right.

We can also view the code execution function by clicking Execute function:

How to use

If you inspect the allTicket component with the React tool, you can see the data flow with props into the child elements:

How to use

If you are inspect a React element on the page in the Elements tab, and then switch over to the React tab, that element will be automatically selected in the React tree. Using the search tab, we can also search for the component by name.

If you also need to trace updates for the component, you need to select the top checkbox, Trace React Updates.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset