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

Computed re render is inconsistent. #10966

Closed
Cheese-Yu opened this issue May 17, 2024 · 2 comments
Closed

Computed re render is inconsistent. #10966

Cheese-Yu opened this issue May 17, 2024 · 2 comments

Comments

@warunacds
Copy link

warunacds commented May 17, 2024

As I understand what's happening here, plusOne is a computed property of count that returns a copy of count, so when you change plusOne, it wants to trigger Vue's reactivity system.

Changing the handleClick function to change count directly will trigger the reactivity system.

const handleClick = () => {
  count.value.push(123);
}

as per

function onChange() {
  plusOne.value.push(321);
  msg.value = '';
}

When msg changes, DOM get updates, and that will render the new values in plusOne

@LinusBorg
Copy link
Member

Correct analysis by @warunacds

Your computed returns a copy of the reactive array, and that copy is plain, non-reactive. changing it (i.e. by pushing to it) will not trigger any reactive effects.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 1, 2024
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

3 participants