My FeedDiscussionsHeadless CMS
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 cancel fetch when the screen unmounts?

Shad Mirza
·Apr 3, 2019

I'm having a bit of an issue with asynchronous fetch operation. Fetch operation starts on componentWillMount() and if causes issue if the user navigates back before a response is generated.

I need a workaround to not update state with data response if the user has already unmounted the screen. i.e., cancel fetch when the screen unmounts.