Chapter 104: Vue ‘renderTracked’ Lifecycle Hook

RenderTracked

This is not a hook you will use every day — or even every month. Most Vue developers never touch it in production code. But once you understand what it does, you will have a much deeper mental model of how Vue’s reactivity system actually works under the hood — and you will be able to debug very tricky performance issues that almost no one else can explain.

So let’s go slow, step by step, like I’m drawing the reactivity graph on the whiteboard.

1. What is renderTracked? (Very clear mental model)

renderTracked (and its sibling renderTriggered) are reactivity debugging hooks.

They let you observe exactly when Vue starts/stops tracking a reactive dependency during the render phase of your component.

In simple words:

Every time Vue renders your component (first mount + every update), it does this:

  1. Starts a new render tracking session
  2. Runs your render function / template
  3. Every time your template / render function reads a reactive value (ref.value, reactiveObj.prop, computed value…) → Vue tracks that value as a dependency
  4. When render finishes → Vue stops tracking and remembers: “These 17 refs/computeds were read → if any of them changes later → I must re-render this component”

renderTracked is called every single time Vue starts tracking a new reactive value during render.

renderTriggered is called every single time a tracked value actually changes and causes a re-render.

These two hooks are purely for debugging / profiling — they are not meant for production logic.

2. Signature & Arguments (what you actually get)

Composition API (what you use in <script setup>):

TypeScript

The event object has three very useful properties:

Property Type What it tells you
target object / ref / computed The reactive object that was just read (reactiveObj, refImpl, computedRef)
key string | symbol Which property was accessed (‘count’, ‘user.name’, Symbol(‘value’) for ref.value)
type string What kind of operation happened: • ‘get’ (normal read) • ‘has’ • ‘iterate’ (for-in / Object.keys)

3. Real Example – Seeing Exactly Which Dependencies Are Tracked

vue

What you see in console when you click “+1 A” multiple times:

text

→ You see exactly which refs/computeds Vue tracked during render → When you change countA, Vue knows to re-run render because it previously tracked countA.value

4. Why renderTracked / renderTriggered are rarely used in production

They are debugging/profiling tools, not business logic hooks.

You use them when:

  • You want to understand why a component re-renders too often
  • You suspect unnecessary dependency tracking (wasted performance)
  • You are optimizing a very performance-sensitive component (dashboard with 1000+ items, real-time feed…)
  • You are writing Vue devtools plugins or advanced reactivity debugging tools

In normal application code → you almost never need them.

5. Quick Summary Table – renderTracked in 2026

Question Answer / Reality in 2026
When does it run? Every time Vue starts tracking a reactive dependency during render
Is it called on every render? Yes — multiple times per render (once per tracked access)
Is DOM available? No — runs during render phase, before DOM patch
Do modern developers use it? Very rarely — mostly for debugging / profiling
Modern name onRenderTracked & onRenderTriggered
Still asked in interviews? Occasionally — to check deep understanding of reactivity
Typical real use Find why component re-renders unnecessarily

Pro Tips from Real Projects (Hyderabad 2026)

  • Add onRenderTracked + onRenderTriggeredtemporarily when a component re-renders too often → log dependencies → find unnecessary reads
  • Use Vue Devtools → Timeline first — it already shows re-render reasons; use these hooks only when you need more detail
  • Never put business logic in these hooks — they run many times per render → performance killer
  • In performance-critical components (virtual lists, real-time charts) → use these to prove which refs are causing re-renders
  • Combine with Vue Devtools → Performance tab — see render time + which hooks run

Your mini homework:

  1. Create the example above
  2. Click “+1 A” multiple times → watch console logs → see exactly what Vue tracks
  3. Click “+1 B” → see that doubleA is not tracked → no unnecessary re-render
  4. Add a useless {{ someUnusedRef.value }} in template → see it tracked → understand waste

Any part confusing? Want full examples for:

  • renderTracked + renderTriggered to debug over-re-rendering?
  • Performance optimization workflow using these hooks?
  • renderTracked in virtual list / large table scenario?
  • Comparison with watch / watchEffect for debugging?

Just tell me — we’ll debug reactivity together step by step 🚀

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *