Skip to content

Commit

Permalink
Fix to also exit early on happy .then() path if promise has been canc…
Browse files Browse the repository at this point in the history
…elled

Kudos to #15228 (comment)
  • Loading branch information
getdave committed Apr 1, 2020
1 parent 1327944 commit 173c8d5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions extensions/blocks/podcast-player/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ const PodcastPlayerEdit = ( {

cancellableFetch.current.promise.then(
data => {
if ( data?.isCanceled ) {
debug( 'Block was unmounted during fetch', data );
return; // bail if canceled to avoid setting state
}
// Store feed data.
setFeedData( data );
},
Expand Down

0 comments on commit 173c8d5

Please sign in to comment.