Performance: Props for parent to child data
MEDIUM IMPACT
This affects the rendering speed and responsiveness by controlling how data flows from parent to child components in Vue.
<template> <ChildComponent :a="complexObject.a" /> </template> <script setup> import { reactive } from 'vue' const complexObject = reactive({ a: 1, b: 2, c: 3 }) </script>
<template> <ChildComponent :data="complexObject" /> </template> <script setup> import { reactive } from 'vue' const complexObject = reactive({ a: 1, b: 2, c: 3 }) </script>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Passing large reactive object as prop | High (many reactive dependencies) | Multiple reflows on any change | High paint cost due to frequent updates | [X] Bad |
| Passing only needed primitive props | Low (minimal reactive dependencies) | Single reflow on prop change | Low paint cost with fewer updates | [OK] Good |