0
0
Vueframework~8 mins

Props drilling problem in Vue - Performance & Optimization

Choose your learning style9 modes available
Performance: Props drilling problem
MEDIUM IMPACT
This affects the rendering speed and responsiveness by increasing the number of component updates and re-renders due to passing props through many layers.
Passing data from a top-level component to a deeply nested child component
Vue
<Parent>
  <Child1 />
</Parent>

// Use provide/inject or a global store to share data directly with Child3 without passing through Child1 and Child2
By using provide/inject or a store, only the components that need the data re-render, reducing unnecessary updates.
📈 Performance GainReduces re-renders and prop updates to only relevant components, improving INP and lowering CPU load.
Passing data from a top-level component to a deeply nested child component
Vue
<Parent>
  <Child1 :data="data">
    <Child2 :data="data">
      <Child3 :data="data" />
    </Child2>
  </Child1>
</Parent>
Each intermediate component must receive and pass down props even if they don't use them, causing unnecessary re-renders and prop updates.
📉 Performance CostTriggers multiple re-renders and prop updates across all intermediate components, increasing INP and CPU usage.
Performance Comparison
PatternDOM OperationsReflowsPaint CostVerdict
Props drilling through many componentsMany components receive and pass propsMultiple reflows triggered by each re-renderHigh paint cost due to repeated updates[X] Bad
Using provide/inject or global storeOnly components that consume data updateSingle or minimal reflows triggeredLower paint cost due to fewer updates[OK] Good
Rendering Pipeline
Props drilling causes many components to receive new props and re-render, triggering multiple layout recalculations and paints.
JavaScript Execution
Style Calculation
Layout
Paint
⚠️ BottleneckJavaScript Execution and Layout due to repeated re-renders of intermediate components
Core Web Vital Affected
INP
This affects the rendering speed and responsiveness by increasing the number of component updates and re-renders due to passing props through many layers.
Optimization Tips
1Avoid passing props through components that don't need them.
2Use provide/inject or a global store to share data with deeply nested components.
3Fewer re-renders mean better interaction responsiveness (INP).
Performance Quiz - 3 Questions
Test your performance knowledge
What is the main performance problem caused by props drilling in Vue?
AExcessive CSS recalculations
BToo many DOM nodes created
CUnnecessary re-renders of intermediate components
DBlocking network requests
DevTools: Performance
How to check: Record a performance profile while interacting with the app. Look for many component re-renders and long scripting times related to prop updates.
What to look for: High scripting time and many repeated component renders indicate props drilling issues.