Skip to content

Can the reference of an object be kept when it's put in $state([])? #16245

Closed as duplicate of#15877
@ratrakone

Description

@ratrakone

Describe the problem

when i create an object and want to push it to two different arrays, like a flat and 2d array it loses the reference.
or when creating components, where there are items and _items i need to use the last element of the array because it's copied.
i can live with it, because there are workarounds, but with complex data it is easier to get lost.
here's a playground with latter example, try typing in the inputs

Describe the proposed solution

if it is somehow possible to retain the same object reference when putting it in a $state() it would be delightful

Importance

would make my life easier

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