[Vuejs]-Why modifiying private data results in firing onUnmount?

3๐Ÿ‘

โœ…

If you change a variable programmatically in your code when you have your app is started in dev env with hot-reload, a changed component will be re-rendered (it will be unmounted and mounted again).

But if you change a variable "in a natural way" for example in a some method that called by any event (by button click) a component will not be unmounted but just updated.

For example, try to add a button that changes the variable and see what lifecycle events will be called:

<button @click="name_ = name_ + ' changed'">CLICK</button>

Leave a comment