Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
With React, we never touch the actual DOM directly. React only manages what gets rendered into the DOM, so it can be tricky to debug your UI in the browser. The React Developer Tools extension gives you a big productivity boost when working with React. It lets you inspect your React component hierarchy in the Chrome and Firefox Developer Tools.
-
0:00
With React, we never touch the actual DOM directly,
-
0:02
React manages what it's rendered into the DOM and what should appear on the screen.
-
0:07
So it can be tricky to debug your UI in the browser.
-
0:10
For instance, how do you map the React component to your building,
-
0:14
to what you see the developer tools inspector?
-
0:17
Fortunately, the engineers at Facebook created the React Developer tools
-
0:21
extension to give you a bid productivity boost when working with React,
-
0:25
let's take a look.
-
0:26
React Dev tools is an extension that let's you inspect your
-
0:29
React component hierarchy in the Chrome and Firefox developer tools.
-
0:34
The first thing we'll do is download and install the tools.
-
0:37
I'll open a new tab and just Google React DevTools.
-
0:41
I'm using Chrome, so I'll click the link to the Chrome Web Store.
-
0:46
React Devtools is also available for Firefox and as a standalone app for
-
0:50
Safari, you can find the links to those in the teacher's notes with this video.
-
0:54
Next, click the green add to Chrome button to install the tools.
-
0:59
I have already installed them, so
-
1:01
now that they're installed any time I visit a website or app that's built using
-
1:06
React I'll see the React extension icon light up in my tool bar.
-
1:10
For example, if I switch over to the scoreboard app a tooltip
-
1:14
pops up letting me know that this page is using the development build of React.
-
1:19
And if we have a look at the React site,
-
1:21
it notifies us that this page is using the production build of React.
-
1:28
So now if you open your browser's developer tools,
-
1:32
you should see a new tab called React.
-
1:35
Click on the tab and you will see the full component tree that makes up our app.
-
1:41
This is the React code that underlies our UI.
-
1:44
You can inspect your component hierarchy similar to
-
1:47
how you inspect HTML elements in the Elements pane.
-
1:50
So the first thing we see is our App component.
-
1:53
Click the arrow to expand the component, we see the scoreboard, div,
-
1:58
and the child Header and Player components.
-
2:01
Expand the player component and we see its elements in child component, the Counter.
-
2:07
The tool offers handy shortcuts to help you be productive and
-
2:10
quickly debug your apps.
-
2:12
For example, you can use the arrow keys to navigate up and down your component tree.
-
2:17
You can right click any component, select Find DOM node, and
-
2:22
it will switch over to the Elements pane and show you the corresponding DOM node.
-
2:28
Another useful tip is that if you inspect a React element on
-
2:33
the page using the regular elements tab.
-
2:37
Then switch over to the React tab,
-
2:40
that element will be automatically highlighted in the React component tree.
-
2:44
Finally, one feature I like to use is the search bar to find components by name.
-
2:49
For example,
-
2:50
if I type Player into the search bar it will show me all the Player components.
-
2:56
Type Counter and I immediately see the Counter component.
-
3:01
And there's a whole lot more you can do with React Dev tools including inspecting
-
3:05
a component's properties and the state of your application or
-
3:09
its data over here in the right pane.
-
3:11
And you're gonna learn a whole lot more about properties and
-
3:13
states starting in the next video.
-
3:14
We're going to be using React Dev tools to understand more about how React works and
-
3:20
how our application is running.
-
3:22
So, I suggest you install them now.
-
3:24
Whenever I visit sites built with React, I like to inspect them with React Dev tools
-
3:29
to see how they were built, so I encourage you to do the same.
-
3:32
You'll often learn something new or pick up new tips along the way.
-
3:36
Now we have the basic shape of our application, however, it's static.
-
3:41
So in the next stage, you'll learn how to insert dynamic information
-
3:45
into your components with properties or props.
-
3:48
See you soon.
You need to sign up for Treehouse in order to download course files.
Sign up