react run componentDidMount code example
Example 1: component did update arguments
componentDidUpdate(prevProps, prevState) {
// only update chart if the data has changed
if (prevProps.data !== this.props.data) {
this.chart = c3.load({
data: this.props.data
});
}
}
Example 2: shouldcomponentupdate default return
By default, shouldComponentUpdate returns true, but you can override it to return false for cases that you do not want a re-render.