Сначала я добавил журналы в консоли для каждого перехвата жизненного цикла
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>;
}
}
После этого в консоли все методы до componentDidMount
вызываются дважды без обновления состояния.
Это сообщения консоли
![i don't understand why is the constructor being called twice](https://i.stack.imgur.com/SAB0Y.png)