Vue · Junior · Question 38 of 75
How can a deeply nested component receive a value without passing props through every level?
// ancestor
provide("theme", theme);
// any descendant
const theme = inject("theme");- ✓Correct answer: With
providein an ancestor andinjectin the descendant - 2With
defineProps({ deep: true }) - 3With
this.$rootin every component
Explanation
provide/inject avoids prop drilling. If you provide a ref, the injected value stays reactive. For app-wide state, Pinia is usually a better fit.