First i added logs in the console for every life cycle hooks
class CircleA extends Component {
constructor(props) {
super(props);
this.state = {
name: "Circle",
};
console.log("Circle-A constructor");
}
static getDerivedStateFromProps(props, state) {
console.log("Circle-A getDeriveStateFromProps Method");
return null;
}
componentDidMount() {
console.log("Circle-A componentDidMount Method");
}
render() {
console.log("Circle-A render method");
return <div>Circle-A</div>;
}
}
After then, on the console every methods until componentDidMount
are being called twice without updating the state.
These are the console messages