Skip to content

Cancel interaction promise when component unmounts#91

Merged
jasongaare merged 3 commits intojasongaare:masterfrom
mackenziekira:patch-1
Sep 14, 2020
Merged

Cancel interaction promise when component unmounts#91
jasongaare merged 3 commits intojasongaare:masterfrom
mackenziekira:patch-1

Conversation

@mackenziekira
Copy link
Copy Markdown
Contributor

Prevent dev warning:

Warning: Can't perform a React state update 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 %s.%s, the componentWillUnmount method,

Prevent dev warning:

```
Warning: Can't perform a React state update 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 %s.%s, the componentWillUnmount method,
```
actually set value
Copy link
Copy Markdown
Owner

@jasongaare jasongaare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this simple, elegant solution! If you could just make one quick change I'll get this merged 💪🏻

Comment thread src/tooltip.js Outdated

componentWillUnmount() {
Dimensions.removeEventListener('change', this.updateWindowDims);
this.interactionPromise && this.interactionPromise.cancel();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit-pick, but for readability will you use this like you did below here, please?

if (this.interactionPromise) {
     this.interactionPromise.cancel();
}

@mackenziekira
Copy link
Copy Markdown
Contributor Author

thanks @jasongaare, just updated 👍

@mackenziekira
Copy link
Copy Markdown
Contributor Author

@jasongaare okay to merge this?

@jasongaare jasongaare merged commit 5f70cdf into jasongaare:master Sep 14, 2020
@jasongaare
Copy link
Copy Markdown
Owner

Released in version 1.1.11

sorry for the delay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants