shouldComponentUpdate
It execute with condition.
Eg:
class App extends React.Component {
constructor() {
super();
this.state={
count:0
}
}
shouldComponentUpdate(){
if(this.state.count<5){
return true;
}
}
render() {
return (
<>
<button onClick={()=>this.setState({count:this.state.count+1})}>Update Counter</button>
</>
);
}
}
}
}
© www.thecoderjob.com. All Rights Reserved. Designed by HTML Codex