In the dependency array you need to pass only the name of the function, just like below:

useEffect(() => {
   console.log('count useEffect');
}, [getTotalCount]); // not like => getTotalCount()

The code was calling also the function like getTotalCount() but only the name is needed, you don't need to call that.

I hope that helps!

Related Query

More Query from same tag