Steps to Reproduce:
It's a race condition so it doesn't work every time.
- From the search screen, select a search result and select the "close" softkey before the article has finished loading
Actual Results:
Message in console:
Can't call "this.setState" on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
Expected Results:
The first call is cancelled when the second one is issued. The general pattern to fix this is the following
useEffect( () => { const handler = doApiCall() handler.then( data => setState(data) ) return () => { // do something here that will prevent handler.then() from being called // since this component is unmounting handler.abort() } }, [] )