Should get default value if perent send null in props.
See original GitHub issueVersion
2.5.17
Reproduction link
https://jsfiddle.net/j97btnex/35/
Steps to reproduce
Child component should use default value. When parent send null in props.
Parent
<child :data="some_data_that_give_null_value"
></child>
Child.
<script>
export default {
props: {
data: {
type: Number,
default: 99,
},
},
mounted() {
console.log(data);
},
}
</script>
What is expected?
99
What is actually happening?
null
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Default value for prop - reactjs - Stack Overflow
I want to assign default value to the prop so if the value for the "myText" prop is not passed down to the...
Read more >A complete guide to React default props - LogRocket Blog
Cover three ways to implement default props in React and provide default values for props that are not required by the component.
Read more >Props! — and how to pass props to components in React ...
Basically, JSX mixes HTML with JavaScript to get the best of both worlds. import React, { Component } from 'react';class App extends Component...
Read more >Passing Props to a Component - React Docs
The default value is only used if the size prop is missing or if you pass size={undefined} . But if you pass size={null}...
Read more >useForm | React Hook Form - Simple React forms validation
The defaultValues prop is used to populate the entire form values. It supports both sync and async set form default values. You can...
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
I imagine this would break quite a few things. If you want the default value, pass
undefined
instead.https://jsfiddle.net/emn64yxz/