Inherit/Bind all props from parent
See original GitHub issueAllow child component to auto inherit props from its parent.
<!-- ComponentA.vue -->
<template>
<div>{{ hello }}</div>
</template>
<script>
export default {
props: {
hello: String,
},
};
</script>
<!-- ComponentB.vue -->
<template>
<div>
<component-a></component-a> World!
<!-- or -->
<component-a v-props></component-a> World!
</div>
</template>
<script>
import ComponentA from './ComponentA.vue';
export default {
props: { ...ComponentA.props },
components: { ComponentA },
};
</script>
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
VueJS pass all props to child component - Stack Overflow
Once you are satisfied with all the props, then you can use v-bind="$props" inside your child component to retrieve all the props.
Read more >Pass all props to children in Vue - DEV Community
You can do this for many levels of components, but remember that the props any child needs must be declared in all parents....
Read more >How to Pass All Props to a Child Component in React - Medium
Being able to share all props from parent to child component in React lets you easily break your app up into small components....
Read more >How to Pass Props Object from Child Component to Parent ...
Once state changes for a component which is passed as props down to the child component, then we see the app re-render again....
Read more >Props | Vue.js
All props form a one-way-down binding between the child property and the parent one: when the parent property updates, it will flow down...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, thanks for filling this issue. Inheriting everything is an anti-pattern, and had been removed from Vue long ago, so please declare the props specifically.
I like to use a rendered function + functional component: