vuejs / core

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
https://vuejs.org/
MIT License
47.84k stars 8.35k forks source link

dependency collection failures, changes to unused props also trigger render #4896

Open danranVm opened 3 years ago

danranVm commented 3 years ago

Version

3.2.21

Reproduction link

sfc.vuejs.org/

Steps to reproduce

Open your browser's console

What is expected?

The log will only be executed once.

What is actually happening?

The log is executed all the time.

posva commented 3 years ago

This might be expected as passed props are used in the generated JS to know when to render again.

You can use v-memo="msg" (or [msg]) to tell the component not to render if msg didn't change

Bigfish8 commented 3 years ago

It is Intentional.It involves active update or passive update of components. You can use object to aviod unnessary update. sfc.vuejs.org/

danranVm commented 3 years ago

image

https://v3.vuejs.org/guide/reactivity.html#how-vue-tracks-these-changes

Does this seem inconsistent with the description in the documentation, or is there a problem with my understanding? In addition, in vue2.x, the behavior is what I expected. see: https://codesandbox.io/s/nifty-smoke-8tz7n?file=/src/App.vue

yyx990803 commented 3 years ago

I think this has been raised before and was marked as enhancement. TLDR: the current behavior ensures correctness in edge cases, especially when $attrs are involved (which are non-reactive).

edison1105 commented 3 years ago

duplicated of #1181