The product list in your Vue app is stuck on a spinner. Vue is a JavaScript framework for building interfaces, like React. The Elements panel only shows <div class="spinner">. That panel doesn't show which component is still loading: true, or why.
Like React, Vue and Angular (a framework made by Google) have DevTools extensions of their own. The extension adds a tab that reads components to the browser's DevTools. So instead of a pile of <div>s, you see the component tree and each component's state. The Elements panel is like looking at a house from outside: bricks, paint and windows. Framework DevTools are like the floor plan of that house: the name of every room (component), and what's in the cupboards of each room (state).
Install the right extension
| Framework | Extension name | Notes |
|---|---|---|
| React | React Developer Tools | Chrome, Firefox, Edge |
| Vue | Vue.js devtools | Chrome and other Chromium browsers, and Firefox. Version 7 and later are for Vue 3 only; a Vue 2 app needs the old (v6) extension. There is also a Vite plugin, vite-plugin-vue-devtools. |
| Angular | Angular DevTools | Chrome and Firefox. Only works on a development build. |
Once it is installed, open the app in development mode, then open DevTools: a Vue or Angular tab appears. In a production build, both tabs are off by default. For Angular, use Angular DevTools, not Augury, an old tool that is no longer developed.
In the exercise, write the official names exactly, capital letters included. pickDevTools only maps a framework name to an extension name:
function pickDevTools(framework) {
const tools = {
react: "React Developer Tools",
vue: "Vue.js devtools",
angular: "Angular DevTools",
}
return tools[framework]
}
Components: the component tree and its state
The Components tab shows components as a tree. This is the app in the exercise and in the Lab, with each component's state to the right of its name:
App { user: null }
├─ Header { loggedIn: false }
└─ Main { view: "list" }
└─ ProductList { items: [], loading: true }
- Click a component, and the panel beside it shows what's inside. Vue shows props, state from
setup(refandreactive, where a Vue component keeps data that can change), andcomputed(a value calculated from other data). Angular shows inputs (data from the parent component), outputs (events sent to the parent) and other properties. - Values can be edited live. Change
loadingtofalse, and the component renders again. This is a quick way to test a guess without changing code. - Both have a button to pick an element on the page, then jump to its component. In Angular, the selected component can be used in the Console panel as
$ng0.
In the exercise, you write a search in this tree: walk it from the root (the top component, App), then return the path to the first component whose state matches. The condition is given as a function, predicate:
function findComponentByState(tree, predicate) {
function search(node, path) {
const here = [...path, node.name] // the path up to this node
if (predicate(node.state)) return here
for (const child of node.children || []) {
const found = search(child, here)
if (found) return found // stop at the first match
}
return null
}
return search(tree, []) || [] // no match: an empty array
}
findComponentByState(tree, (s) => s.loading === true).join(">") // "App>Main>ProductList"
This is the order of the components visited for the condition loading === true:
| Visited | loading === true? |
Path |
|---|---|---|
| App | no | App |
| Header | no, and no children | App > Header |
| Main | no | App > Main |
| ProductList | yes | App > Main > ProductList |
Profiler: who works for nothing
Change detection is Angular checking whether a component's view needs updating. One round of checking is called a cycle. Angular has two strategies (ways to choose what is checked):
- Default (now named
Eager, and the nameDefaultis deprecated, which means it will be removed): every cycle checks every component. - OnPush: a component is only checked in four cases. Its input gets a new reference (a new object or array), an event comes from inside that component, a signal (an Angular reactive value) it reads changes, or the code calls
markForCheck().
Since Angular 22, OnPush is the default strategy. So the profile below, and the OnPush advice in the exercise, apply to an app on Angular 21 or older, or a component set to Eager.
In the Profiler tab of Angular DevTools, click Start recording, use the app, then stop. Each bar is one change detection cycle: the taller it is, the longer it took. Click a bar to see which components were checked in that cycle. These are five cycles from the exercise:
| Cycle | Duration | Input changed? | Check |
|---|---|---|---|
| 1 | 2 ms | yes | needed |
| 2 | 3 ms | no | wasted |
| 3 | 2 ms | no | wasted |
| 4 | 4 ms | no | wasted |
| 5 | 3 ms | yes | needed |
The table has 3 wasted checks out of 5 cycles, more than half (2.5), so the advice is OnPush. The average duration is (2 + 3 + 2 + 4 + 3) / 5 = 2.8, rounded to 3. In the exercise, this function calculates all three:
function analyzeChangeDetection(cycles) {
const unnecessaryChecks = cycles.filter((c) => c.checked && !c.inputChanged).length
const avgDuration = Math.round(cycles.reduce((sum, c) => sum + c.duration, 0) / cycles.length)
const recommendation = unnecessaryChecks > cycles.length / 2 ? "OnPush" : "OK"
return { unnecessaryChecks, avgDuration, recommendation }
}
In Vue, the tool is the Timeline tab, which records performance events, including how long each component took to render and update. If ProductList keeps rendering again while its data stays the same, its parent component, Main, is usually passing a new array every time Main renders. In the code below, the wrong way is in the first two comment lines. The template is a Vue component's HTML, and :items sends the prop items to ProductList:
// In Main's template: :items="products.filter((p) => p.active)"
// filter makes a new array every time Main renders, so the prop always "changes"
const activeProducts = computed(() => products.value.filter((p) => p.active))
// In Main's template: :items="activeProducts"
computed keeps its result and gives the same array for as long as products doesn't change. So ProductList doesn't need to render again. For very large data, shallowRef stops Vue from tracking changes to every item inside it.
What each one has of its own
- Vue DevTools: the Pinia, Router, Timeline and Graph tabs. Pinia shows the stores (places for data that many components share) with their state, which you can edit. Router shows the list of routes (the page addresses in the app) and the active route. Graph shows a component's reactive dependencies: which data it uses.
- Angular DevTools: Injector Tree (Angular 17 and later) and Router Tree. Angular has layered dependency injection (DI): Angular itself gives a service (shared code) to a component, and a service can be provided at the root (the app level), on a route or on a component. Injector Tree shows which injector (service provider) gave a service to a component. This helps when one service turns out to have different state in two places. Only Angular DevTools has this.
- React Developer Tools: the Components and Profiler tabs.
🎯 A debugging flow with framework DevTools
- Repeat the steps until the bug happens again.
- Open Components, find the component, then read its props and state.
- Edit the state live to test your guess.
- If the problem is slowness, record in the Profiler (Angular) or Timeline (Vue).
- If the data is shared, check the store tab (Pinia).
- Still stuck? Set a breakpoint in the Sources panel.
⚠️ From the missing tab to the OnPush cutoff
- No Vue or Angular tab. Usually a production build, or a Vue 2 app with the version 7 extension.
- A typo in the extension name. In the exercise, the result of
pickDevToolsis compared as a string:Vue.js devtools(devtools in lowercase),Angular DevTools,React Developer Tools. - No match gives
null.findComponentByStatemust return an empty array. Then.lengthis 0 instead of an error. - The OnPush threshold. In the exercise, the advice is
"OnPush"when wasted checks are more than half of the cycles (>). Otherwise, the result is"OK". With only one cycle, whose input changed, the result is"OK". The average is taken over every cycle, then rounded withMath.round.
TL;DR: Vue and Angular (JavaScript frameworks for building interfaces, like React) have DevTools extensions of their own. The official names are React Developer Tools, Vue.js devtools (version 7 and later for Vue 3) and Angular DevTools. They all work on a development build. The Components tab shows the component tree with its props and state, and you can edit the values live. In the exercise, findComponentByState walks the tree from the root to the first component that matches, and returns its path (App>Main>ProductList), or [] when nothing matches. Angular's Profiler records change detection cycles (one round of Angular checking the components' views). A check while the input (data from the parent component) didn't change is wasted. When more than half of the checks are wasted (3 out of 5), the advice is OnPush. This is for Angular 21 or older, because since Angular 22 OnPush is the default. In Vue, the Timeline tab shows renders that happen too often. The usual cause is a parent component that passes a new array on every render, and computed (a value that is kept and only calculated again when its data changes) fixes it. Injector Tree only exists in Angular DevTools, because Angular has layered DI (dependency injection: Angular gives services to components).
⚡ Install the right extension
Meaning: Vue and Angular (JavaScript frameworks for building interfaces, like React) have DevTools extensions of their own, which add a tab that reads components. The official names are React Developer Tools, Vue.js devtools (version 7 and later for Vue 3) and Angular DevTools. They all work on a development build. If the Vue or Angular tab doesn't appear, check the build first.
⚡ The component tree and its state
Write:
App { user: null }
├─ Header { loggedIn: false }
└─ Main { view: "list" }
└─ ProductList { items: [], loading: true }
Meaning: The Components tab shows components as a tree, not a pile of <div>s. To the right of each name is that component's state. Click a component to see its props and state. Values can be edited live: change loading to false, and the component renders again.
⚡ Re-rendering with the same props
Write:
const activeProducts = computed(() => products.value.filter((p) => p.active))
// In Main's template: :items="activeProducts"
Meaning: This is Vue code. The Main component sends the list of active products to ProductList through the prop items. If Main's template (the component's HTML) calls filter directly, a new array is made every time Main renders. So the prop always counts as changed, and ProductList renders again too. computed keeps its result and gives the same array for as long as products doesn't change.
⚡ What only Angular has
Guess first: in Angular, a service (shared code) is given to a component by Angular itself, from one of several levels (dependency injection). Which feature shows where that service came from, and exists only in Angular DevTools?
Injector Tree. It shows which injector (service provider) gave a service to a component.
Meaning: Angular's Profiler tab records change detection cycles: each round of Angular checking whether a component's view needs updating. A check while the input (data from the parent component) didn't change is wasted. When more than half the checks are wasted, the advice is the OnPush strategy: a component is only checked when something about it changes. This is for Angular 21 or older, because since Angular 22 OnPush is the default.