Subscribe on changes!

Bug with passing object with ref to props

avatar
Oct 24th 2021

Version

3.2.20

Reproduction link

sfc.vuejs.org/

Steps to reproduce

  1. run reproduction
  2. open browser dev tools

What is expected?

Expected Ref to be unwrapped

What is actually happening?

In dev tools:

[Vue warn]: Invalid prop: type check failed for prop "msg". Expected String with value "[object Object]", got Object  
  at <Hello msg=Ref< "hello" > > 
  at <Repl>

Full example of usage: https://codesandbox.io/s/laughing-zhukovsky-17qpf?file=/src/App.vue

avatar
Oct 24th 2021

This behaviour is correct. You pass a non-reactive object, and unwrapping only happens for reactive objects.

avatar
Oct 24th 2021

This behaviour is correct. You pass a non-reactive object, and unwrapping only happens for reactive objects.

What about this example? if use reactive object, computed not recalculate https://codesandbox.io/s/laughing-zhukovsky-17qpf?file=/src/App.vue

avatar
Oct 24th 2021

This behaviour is correct. You pass a non-reactive object, and unwrapping only happens for reactive objects.

In repl msgWrapper not reactive, but msgWrapper.msg - ref: <other :msg="msgWrapper.msg" />

avatar
Oct 24th 2021

What about this example? if use reactive object, computed not recalculate

useDataLvl1 returns a reactive object - which will unwrap the message ref. So when you spread this reactive object into a new one in useDataLvl2, the new object doesn't get the message ref, only its value at that time.

Also: expected.

avatar
Oct 24th 2021

I'm closing this because what you demonstrated here is normal behavior, not a bug. I understand that you may have doubts how to deal with this situation for your usecase.

Please ask the community for help on chat.vuejs.org