score:3

Accepted answer

no, once the class component created, react didn't create a new instance of it unless the component is unmounted and mount again.

you can check if the constructor is called many times when the parent component renders.

class mycomponent extends component {
    constructor(props){
        super(props);
        console.log("new instance of mycomponent is created");
    }
}

score:2

enter image description here

react compares the current element tree structure returned from the render() method. react uses the generated keys (or assigned keys) to match each element to a component instance. react determines if we have new instances (a.3), removing instances (a.0.1) or are updating existing instances (a, a.0, a.0.0).

if the keys are the same, then react will pass the props to the existing instance, kicking off its update life cycle. if we have added new components or changed keys, react will create new instances from the element data. these new components then enter the birth/mounting phase.

more info


Related Query

More Query from same tag