I have a component(showing a list) that renders before the props (redux) are updated ( there is new item that is added to the list and should be displayed but it is not , unless the app is reloaded) . I wrote this to prevent this behaviour :
shouldComponentUpdate(nextProps, nextState) {
if (this.props.data === nextProps.data) {
return false;
} else {
return true;
}
}
componentWillUpdate(prevProps){
if(prevProps.data !== this.props.data){
this.props.onFetchAction()
}
}
it makes the component update before the rendering , BUT on the console the onFetchAction() is fired non stop. How can I prevent this ????? any help would be apreciated .