Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM is not updated when shallow array is modified #964

Closed
sionzee opened this issue Apr 15, 2020 · 2 comments
Closed

DOM is not updated when shallow array is modified #964

sionzee opened this issue Apr 15, 2020 · 2 comments

Comments

@sionzee
Copy link

sionzee commented Apr 15, 2020

Version

3.0.0-alpha.12

Reproduction link

https://jsfiddle.net/xjuamt5y/4/

Steps to reproduce

  1. Open the reproduction case.
  2. Open console
  3. Click anywhere in the rendered part

You should see message "Adding to array"

What is expected?

To re-render the DOM with values from Array

What is actually happening?

Nothing is updated.


When I add another ref there and modify the ref, it will re-render whole DOM with proper values.

Used shallowRef because of #962

@sionzee
Copy link
Author

sionzee commented Apr 15, 2020

Additional Comment

Even when shallowRef is not making value reactive, what should be the proper way to update array of components?

In the reproduction case there is structure with comp and id. That makes sense why it is not updated. (realized after opening the issue) But if we cannot use ref on component. What should be proper way to update: Array<Component>?

@yyx990803
Copy link
Member

A shallowRef only tracks mutation of its own .value property. Mutating the array inside won't be reactive. If you want to track the mutation of the array you should be using shallowReactive([])

@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants