Going through the LWC documentation for track decorator, I see this part:
When manipulating complex types like objects and arrays, you must create a new object and assign it to the field for the change to be detected.
To avoid such issues when working with complex objects, use the @track decorator to deeply tracks mutations made to the field value
I did a little test with the following component without using the @track decorator:
View
<template>
<lightning-card title="Re-rendering test">
<div class="slds-m-around_medium">
<h2 class="slds-text-heading_medium">
<div>Variable value: {variable}</div>
<div>Object property value: {object.name}</div>
</h2>
<div class="slds-p-around_medium lgc-bg" >
<lightning-input type="text" label="Enter some text" onkeyup={handleKey}></lightning-input>
</div>
</div>
</lightning-card>
</template>
Controller
import {LightningElement} from 'lwc';
export default class RenderTest extends LightningElement {
variable = 10;
object = {
name: 'John'
}
handleKey(event){
this.variable = event.target.value;
this.object.name = event.target.value;
}
}
Component after initial render

I expected the object variable not to re-render in the view after I modified the input. However, my component re-renders perfectly fine after modifying the input:
So what exactly happened here? Did the whole Lightning Card re-render because one of the variables was of a primitive type? And if so, how does this happen - does the whole Template re-render, or only some of its subcomponents?
