vuejs / rfcs

RFCs for substantial changes / feature additions to Vue core
4.87k stars 546 forks source link

`props` object should contain all `props` defined #293

Closed pikax closed 3 years ago

pikax commented 3 years ago

Summary

Odd behaviour when using toRefs(props) if the prop has not been passed

defineComponent({
  props: {
    foo: String,
  },
  setup(props) {
    const { foo } = toRefs(props) // props is `{}` making `toRefs` To return `{}`

    // correct
    const foo = toRef(props, 'foo')
  },
})

Links


Important: Do NOT comment on this PR. Please use the discussion thread linked above to provide feedback, as it provides branched discussions that are easier to follow. This also makes the edit history of the PR clearer.

pikax commented 3 years ago

fixed by https://github.com/vuejs/vue-next/commit/4fe4de0a49ffc2461b0394e74674af38ff5e2a20