Skip to content

One Way Data Binding Documentation Needs Clarity #1362

Closed
@bengreenow

Description

@bengreenow

Please can someone provide some clarity around the statement:

Note that objects and arrays in JavaScript are passed by reference, so if the prop is an array or object, mutating the object or array itself inside the child component will affect parent state.

made here: https://v3.vuejs.org/guide/component-props.html#one-way-data-flow
This note does not specifically tell us to avoid doing this as it an anti-pattern or bad practice. In Vue2 this was definitely considered bad practice because the parent would not react to it but in vue3 this does not seem to be the case we've been modifying array and object props by using toRefs in and are unsure if this is still considered a bad approach.

If so, please could clarity be added to the docs surrounding reference types specifically.

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