A React Copmponent is rendering when its state or propr remain the same. I don't get why it does it rerender/update since the result wouldn't change
class A extends Component {
render() {
console.log("Hello")
return "Foo";
}
}
class App extends Component {
constructor(props) {
super(props);
this.state = { a: "ASDA" };
}
render() {
return (
<div>
<button onClick={()=>this.setState({a: Math.random()}) }>asdsa</button>
<div>{this.state.a}</div>
<A />
</div>
);
}
Whenever I click the button, component A is rerendered (I can see "hello" in the console) I thought React was avoiding many useless rerenderings.