Performance: Props drilling problem
This affects the rendering speed and responsiveness by increasing the number of component updates and re-renders due to passing props through many layers.
<Parent>
<Child1 />
</Parent>
// Use provide/inject or a global store to share data directly with Child3 without passing through Child1 and Child2<Parent> <Child1 :data="data"> <Child2 :data="data"> <Child3 :data="data" /> </Child2> </Child1> </Parent>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Props drilling through many components | Many components receive and pass props | Multiple reflows triggered by each re-render | High paint cost due to repeated updates | [X] Bad |
| Using provide/inject or global store | Only components that consume data update | Single or minimal reflows triggered | Lower paint cost due to fewer updates | [OK] Good |
props drilling in Vue?title from a parent to a child component in Vue?: or full v-bind: syntax.:, uses v-bind:. Both correctly bind the variable parentTitle as a prop.App -> Parent -> ChildApp passes a prop message to Parent, which passes it to Child. What will Child display if message is "Hello"?<template>
<div>{{ message }}</div>
</template>
<script setup>
defineProps(['message'])
</script>message="Hello" to Parent, Parent passes it to Child as prop.message prop correctlymessage prop and displays it inside the div.user from App to Parent and then to Child. You get an error: Property 'user' is not defined in Child. What is the likely cause?Property 'user' is not defined occurs when accessing a prop in the template without declaring it in defineProps in the Child.undefined, not trigger this specific error.user in defineProps -> Option Cprovide/inject allows ancestor components to share data directly with descendants without passing props through every layer.Pass the test and this pattern moves unknown