Skip to content

Triggering a ref passed as a prop does not cause an update in the nested component #7614

Closed
@yurivish

Description

@yurivish

Vue version

3.2.45

Link to minimal reproduction

https://sfc.vuejs.org/#eNqlU01v2zAM/SuED7WDOlI/tku+0GLYYbdhWE91gaoxE7uxJUGiYxSB//uoOB9uV+yyiyHxke9RfPQuurdWbBuMJtHML11pCTxSYxeZLmtrHMEOfKGqyrS/cJUCuXK9Rrc/t4qWxffVCpeUgtEPujaNJsyhg5UzNcTMG594vim9Vf6ACNlfg3ScUaYzvTTaE+SKFMwHkonGFh5KTbc3986pt+R6NJpmGuBYwRC6rapCFdKPwy1JRjBfwI6Zqc9TznFK4BeMNxg4OPZ49XR5Gc4hy1QoKrNOhBAMjUL4/OAk1HKsS+H66ooPgycf5JYVKndq4djZiHMzLSX8LkoPrtEe2gI1PJ+5n4GRUm/NBvMUXhoCKnDf7L7QOmPBKu95uGSOo8wNeh0Hw7AO4da4zb7OqxrZnTeR6YFHxx4H7zxPI/Q4k/0GsPd8IaxtpQj5BjCzi4uKprwsF2uawt6JwESoyU9gt+tDIrjbz0m8mlIncQrxCLpuJsNGMc+h9UnImcfhG4NkaCZPelEa9SszrpUVr95oXk42ki0/AD6LWDNEQoxXKNyzqCCyfiJlo+1mLZamlneMSR44lTWOc1Pf3Yob8eWrzEtPw7hAX49fnGk9OlbMonRALjm4RTd2qHN06P4p9iH3neAH7C/RoNnxfvEAzn/HJz9mjqtS40/eCZ889jN8em/fp+b1nP/j39Ck7g+CjnZe

Steps to reproduce

Observe the output – the two lines should be identical, but they are not.

What is expected?

data is a shallowRef holding an array.

There is a setInterval that updates an array element, then triggers the data shallowRef.

The two lines of output should be the same – the first is the direct output of the App template and the second is the output of a nested Canvas component.

What is actually happening?

For some reason, despite the triggerRef calls, the reactivity does not propagate to the Canvas component instance.

image

System Info

No response

Any additional comments?

Curiously, if I pass the prop as :data='[data]' instead of :data='data', then the two stay in sync.

I think this means that triggerRef causes the data prop to re-evaluate, and since each evaluation returns a new array object ([data]) this causes the Canvas component to be re-rendered.

But I think that data changing should be enough to cause the Canvas component to re-render, and it is puzzling why it doesn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.has workaroundA workaround has been found to avoid the problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions