Skip to content

Destructured prop variables aren't returned from setup()  #11325

@magicandskill

Description

@magicandskill

Vue version

3.4.29

Link to minimal reproduction

https://github.com/magicandskill/vuejs-props-reassignment-reactivity/tree/main

Steps to reproduce

npm install,
npm run dev,
press the add count button,

What is expected?

Props destructuring like this:

const { text, count } = defineProps(['text','count'])

doesn't affect the reactivity of the props within the template because these variables aren't returned from setup().

But reassignment like this:

const props = defineProps(['text','count'])

const text = props.text
const count = props.count

will make the props not reactive in the template because they get returned and mask the props in the template.

These two versions are creating the same variables, so the results should be consistent.

What is actually happening?

Inconsistent behaviors in regard to returned variables from setup().

System Info

No response

Any additional comments?

No response

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