You can add a setTimeout in useEffect and clear that timeout using clean up function. So that you can make sure to call API only when users "stay" on that component for an amount of time. Hope this helps Something like this:
useEffect(() => { const timeout = setTimeout(() => { // call api }, 5000); // 5 seconds return () => { clearTimeout(timeout); }; }, []);
thanks man!, Hope it may helps me.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You can add a setTimeout in useEffect and clear that timeout using clean up function. So that you can make sure to call API only when users "stay" on that component for an amount of time. Hope this helps
Something like this:
thanks man!, Hope it may helps me.