question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should get default value if perent send null in props.

See original GitHub issue

Version

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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
KaelWDcommented, Aug 22, 2018

I imagine this would break quite a few things. If you want the default value, pass undefined instead.

1reaction
KaelWDcommented, Aug 23, 2018
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found