Skip to content

toRaw keeps inner refs #5227

@aantipov

Description

@aantipov

Version

3.2.26

Reproduction link

sfc.vuejs.org/

Steps to reproduce

Documentation https://v3.vuejs.org/api/basic-reactivity.html#toraw says that toRaw can be used as an "escape hatch" from Vue reactivity.

It's not, apparently

Examples:

  1. toRaw(ref('aValue')) gives a ref object instead of 'aValue' string
  2. toRaw({a: 'a', b: ref('b'), c: ['ca', ref('cb')]}) gives an object, keeping all the inner refs
  3. toRaw(reactive({a: 'a', b: ref('b'), c: ['ca', ref('cb')]})) gives an object, keeping all the inner refs

What is expected?

I expect toRaw results in a value completely free from Vue reactivity and all the inner refs be unwrapped.

What is actually happening?

toRaw doesn't unwrap inner refs, hence the result is not completely free from Vue reactivity and ref values need to be accessed using .value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions