My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

How to prevent component remounting and state updating on route change

Indrakant Mishra's photo
Indrakant Mishra
·Aug 3, 2020·

1 min read

Hi, I am calling API in componentDidMount and setting data to state but when i change to another route (no page refresh) and coming back API gets called again and state is updating. This is causing problem since data is huge. Please help me to stop API call or state updating if i go to another route and comeback.