Default value for component props
See original GitHub issueWould be nice to have:
Vue.component("test", {
"props": [{
"name": "visible"
"type": Boolean
"default": true
}]
})
Apologies if there are easy ways to implement this (i.e. not by setting manually in the constructor)
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
React.js: Set a Default value into a prop - Stack Overflow
The defaultProps will be used to ensure that this.props.name will have a value if it was not specified by the parent component.
Read more >ReactJS defaultProps - GeeksforGeeks
The defaultProps is a React component property that allows you to set default values for the props argument. If the prop property is...
Read more >React: Everything about Default Props | by Chidume Nnamdi
defaultProps is a property in React component used to set default values for the props argument. It will be changed if the prop...
Read more >How to specify default value for props in React.js
Well, you can use ES6's object destructuring to specify a default value for the prop. So, previous example can be changed to use...
Read more >How to set default props in React - Educative.io
Props in React are like function arguments. You can use props to send data to a component. Like default values for function arguments,...
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
Props are just data, so what you return in
data
will become the default if the parent didn’t provide it:Although I agree that having the default directly in
props
seems better.Closed via 6afe4c5af5517183f636df4d450fbc508a1f5509