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

useIntl() return object not being updated after changing locale to previously used value #1411

Closed
chrisswordfish opened this issue Aug 12, 2019 · 2 comments

Comments

@chrisswordfish
Copy link

Updated the other day to version 3.1.3 and noticed this immediately. Switching from initial state to a different value (locale: 'en' -> locale: 'es') works fine. All my useIntl hooks are being updated. Switching BACK from (locale: 'es' -> locale: 'en') does not cause a re-render in any of those components.

I re-installed version 3.1.2 and verified the issue no longer occurs. Suspect it is an issue with the caching bug fixes made in 3.1.3

Expected behavior

Changing locale property on IntlProvider triggers all useIntl() hook consumers to update.

Current behavior

Switching the first time works perfectly. Any subsequent switches back to a previously used locale does nothing.

Step to reproduce for BUG REPORT

Create an IntlProvider and pass it a locale value ( from a simple state object ). Change the state (using setState) and verify the locale is changed in a child component which uses useIntl(). Change the state back to the initial state and verify the child components do not re-render with the updated intl object.

Your Environment

Executable Version
npm ls react-intl 3.1.5
npm ls react 16.9
npm --version 6.4.1
node --version 10.15.3

| OS | Version |
| Windows 10 | ------- |

| Browser | Version |
| Chrome | 75.0.3770.142 |

@longlho
Copy link
Member

longlho commented Aug 12, 2019

Can u make a quick codesandbox to demo this? nvm I added a test. Thanks a lot for reporting!

@chrisswordfish
Copy link
Author

No worries, thanks for being so quick to resolve.

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

No branches or pull requests

2 participants