I have an app that allows users to search Tweets about a particular topic. When searched, the Tweets will render on to a list. Once all the Tweets are rendered to the list I want the app to automatically load the new tweets on to the list w/o the user having to do anything. I am attempting to do this by having a setTimeOut function fetching from the API every minute but it just ends up being an infinite loop. How can i achieve this? Doing it with Redux.
List Component
componentDidUpdate(prevProps, prevState) {
if (prevProps.tweets !== this.props.tweets) {
try {
setInterval(async () => {
this.props.fetchPosts(this.props.symbol);
}, 3000);
} catch (e) {
console.log(e);
}
}
}