Design Converter
Education
Last updated on Mar 17, 2025
•6 mins read
Last updated on Mar 17, 2025
•6 mins read
Struggling to keep your React projects running smoothly?
Debugging and improving performance can take up a lot of time. That’s where React DevTools comes in. It’s a handy tool that helps you inspect, debug, and improve your React applications more easily.
In this blog, we’ll walk through everything you need to know — from setting it up to using advanced features.
Let’s get started!
React Developer Tools is an essential toolkit for any React developer. It provides a comprehensive overview of the React component tree, allowing developers to inspect and debug their components with ease. Whether you're a beginner or an experienced developer, React Developer Tools can significantly enhance your workflow.
React DevTools is a browser extension available for popular browsers such as Chrome, Firefox, and Edge. It allows developers to inspect the React component hierarchies in the Chrome Developer Tools. This tool is crucial for understanding and debugging React applications, as it provides insights into the component tree, props, and state.
When you load a page with React components, React DevTools sets a global hook named REACT_DEVTOOLS_GLOBAL_HOOK. React then communicates with this hook during initialization. This communication enables the developer tools to inspect and interact with the React components on the page.
To get started with React DevTools, you need to install the react-devtools package. You can do this using npm or yarn.
Here's how:
You can install the react-dev tools package globally or as a project dependency. To install it globally, use the following command:
1npm install -g react-devtools
Alternatively, add react-devtools as a project dependency using npm or yarn:
1npm install --save-dev react-devtools
or
1yarn add react-devtools --dev
If you prefer to avoid global installations, you can use npx to install react-devtools as a one-time installation:
1npx react-devtools
To launch the standalone DevTools app, run the following command in your terminal:
1npx react-devtools
This will open the standalone DevTools app, allowing you to inspect and debug your React applications.
One of the most powerful features of React DevTools is the ability to inspect component instances. This feature allows you to examine the props and state of your React components directly in the browser console.
You may examine the props and state of the React components in the browser console when debugging JavaScript in Chrome. First, open the Chrome console by pressing F12 or Ctrl+Shift+I. Make sure that the dropdown in the top left corner of the Chrome console says debuggerWorker.js.
Select a React component in React DevTools, and it will be available as $r in the Chrome console. This allows you to inspect its props, state, and instance properties. For example:
1console.log($r.props); 2console.log($r.state);
You can also use the Chrome console to log render timings and inspect the React component tree.
The React Components tab in React DevTools shows the root React components and their subcomponents. This tab is essential for understanding the structure of your React application.
The React Components tab provides a visual representation of the React component tree. You can use this tab to inspect and update the rendered React component tree. The tab won’t show up if the site doesn’t use React or if React can’t communicate with the developer tools.
React DOM is a package that provides DOM-related functionality for React components. It is responsible for rendering the React components to the DOM and managing updates efficiently.
React DevTools offers advanced features such as the Profiler tab, which allows you to record performance profiles to understand the timing of component renders and React commits.
A useful tool for assessing your React application's performance is the Profiler tab. Two props are needed: a onRender callback (function) and an id (string), which React invokes whenever a component in the tree "commits" an update.
1import { Profiler } from 'react'; 2 3function onRenderCallback( 4 id, // the "id" prop of the Profiler tree that has just committed 5 phase, // either "mount" (if the tree just mounted) or "update" (if it re-rendered) 6 actualDuration, // time spent rendering the committed update 7 baseDuration, // estimated time to render the entire subtree without memoization 8 startTime, // when React began rendering this update 9 commitTime, // when React committed this update 10 interactions // the Set of interactions belonging to this update 11) { 12 // Aggregate or log render timings... 13} 14 15<Profiler id="Application" onRender={onRenderCallback}> 16 <App /> 17</Profiler>
React DevTools provides advanced features such as memory profiling and CPU profiling to help optimize performance. These tools allow you to identify performance bottlenecks and optimize your React application accordingly.
The React Developer Tools browser extension is available for popular browsers such as Chrome, Firefox, and Edge. This extension provides a seamless debugging experience for React developers.
To install the React Developer Tools browser extension, follow these steps:
Open your browser and navigate to the extensions store.
Search for "React Developer Tools" and click "Add to Chrome" or the equivalent button for your browser.
Once installed, visit a website built with React to see the Profiler panels.
The browser extension allows you to inspect and update the rendered React component tree. You can use it to debug your React applications directly in the browser.
React Native is a popular framework for building mobile applications using React. React Native DevTools integrates React Developer Tools for a seamless debugging experience.
React Native DevTools provides features such as native element highlighting and selection, identical to the browser extension. This makes it easy to inspect and debug your React Native apps.
For earlier versions of React Native, you can use the standalone build of React DevTools by following the Safari and other browsers guide. This allows you to debug your React Native apps even if you're using an unusual environment.
React DevTools makes debugging and improving React apps much easier. Following the best practices shared in this blog can help streamline the development process and reduce errors.
Keep experimenting with the advanced features and performance tools in React DevTools. The more familiar one gets with it, the smoother the development process will be.
Tired of manually designing screens, coding on weekends, and technical debt? Let DhiWise handle it for you!
You can build an e-commerce store, healthcare app, portfolio, blogging website, social media or admin panel right away. Use our library of 40+ pre-built free templates to create your first application using DhiWise.