The shallowReactive Api deep data changed can cause the view to be update
Version
3.0.4
Reproduction link
Steps to reproduce
please check link.
What is expected?
deep data changed can't cause the view to be update
What is actually happening?
view to be update
I don't know if I didn't understand the shallowReactive API or if the problem was a bug?
It's not a bug rather a normal behavior. View Updating is because changing of shallowReactiveState.name = 'zmj'
not shallowReactiveState.age.number = 1000
deep data change does not trigger watch, but it is still a data change (e.g. shallowReactiveState.age.number
is still modified). So if anyone tries to pull the data, he will see the 1000 rather than the original 99.
Then there is the scope of DOM update. There are optimizations built in so that Vue does not re-render your entire app whenever something changes, but still the scope is not down to every single tiny place where a property is used (default is component scope?). So as long as there is some other stuff triggers an update, vue will figure out the scope of the dom to recalculate and if that scope includes the age.number, the change will be pulled in.
deep data change does not trigger watch, but it is still a data change (e.g.
shallowReactiveState.age.number
is still modified). So if anyone tries to pull the data, he will see the 1000 rather than the original 99.Then there is the scope of DOM update. There are optimizations built in so that Vue does not re-render your entire app whenever something changes, but still the scope is not down to every single tiny place where a property is used (default is component scope?). So as long as there is some other stuff triggers an update, vue will figure out the scope of the dom to recalculate and if that scope includes the age.number, the change will be pulled in.
Thanks! I get it! The shallowReactive Api is actually an optimization way to avoid re-render。
deep data change does not trigger watch, but it is still a data change (e.g.
shallowReactiveState.age.number
is still modified). So if anyone tries to pull the data, he will see the 1000 rather than the original 99.Then there is the scope of DOM update. There are optimizations built in so that Vue does not re-render your entire app whenever something changes, but still the scope is not down to every single tiny place where a property is used (default is component scope?). So as long as there is some other stuff triggers an update, vue will figure out the scope of the dom to recalculate and if that scope includes the age.number, the change will be pulled in.
I want to know which businesses can use it