Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormattedRelativeTime: React state update warning #2727

Closed
JanStevens opened this issue Mar 19, 2021 · 0 comments
Closed

FormattedRelativeTime: React state update warning #2727

JanStevens opened this issue Mar 19, 2021 · 0 comments
Labels

Comments

@JanStevens
Copy link

JanStevens commented Mar 19, 2021

Which package?

react-intl: FormattedRelativeTime

Describe the bug

When using FormattedRelativeTime we notice that we receive a React state warning whenever the component gets unmounted (page change for example).

index.js:1 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 a useEffect cleanup function.
    at FormattedRelativeTime

To Reproduce

Codesandbox URL

https://codesandbox.io/s/formattedrelativetime-state-issues-rp0i1?file=/src/index.tsx

Reproducible Steps/Repo

Steps to reproduce the behavior:

  1. Open the sandbox
  2. Ensure the timer is running
  3. Press the button
  4. In your console see the error

Expected behavior

FormattedRelativeTime should properly clear up timeouts in useEffect so these errors do not happen

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome, Safari, Firefox
  • Version: Latest version

Additional context

Using the latest version of react-intl 5.13.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant