Composition-api: toRefs(props) throws warning

Created on 9 Jun 2020  路  2Comments  路  Source: vuejs/composition-api

Heya! I just updated from 0.5.0 to 0.6.1 and noticed a new warning popping up:

[Vue warn]: toRefs() expects a reactive object but received a plain one.

I noticed this is caused by code like

export default defineComponent({
  props: {
    whatever: String,
  },
  setup(props) {
    const { whatever } = toRefs(props);
  }
});

That pattern has been working wonderfully before, and I was under the impression that props was in fact a reactive object, which in turn would mean toRefs(props) should be valid.

Is this a bug, or am I misunderstanding the reactivity of the props parameter?

Most helpful comment

Is this a bug, or am I misunderstanding the reactivity of the props parameter?

It shouldn't warn when using props, props are reactive. I will create a PR to fix that

All 2 comments

Is this a bug, or am I misunderstanding the reactivity of the props parameter?

It shouldn't warn when using props, props are reactive. I will create a PR to fix that

Thanks for the impressively fast turnaround on this @pikax & @antfu! Y'all rock 鉂わ笍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SJanJan picture SJanJan  路  3Comments

jaryn-kubik picture jaryn-kubik  路  3Comments

sapphi-red picture sapphi-red  路  4Comments

lephuongbg picture lephuongbg  路  3Comments

sseeland picture sseeland  路  4Comments