Skip to content

Option to provide keySelector to #6 workaround #36

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

Closed
wants to merge 1 commit into from
Closed

Option to provide keySelector to #6 workaround #36

wants to merge 1 commit into from

Conversation

smokku
Copy link

@smokku smokku commented Jun 30, 2017

Unfortunately #6 workaround does not help with the case when only messages change (i.e. after downloading new version from server), but locale stays the same.

This change introduces an option to provide own selector setting the key. There isn't one-size-fits-all solution, as every project has own messages structure, so it cannot be fixed for all.

In my case the solution is as simple as:

const keySelector = (intl) => `${intl.locale}-${JSON.stringify(intl).length}`

...
      <Provider store={store}>
        <IntlProvider keySelector={keySelector}>

@ratson
Copy link
Owner

ratson commented Jun 30, 2017

@smokku Thanks for your PR. Would you send another PR with a test case describing the problem, so I could try different approach? I am wondering if there is a better solution for this.

@ratson
Copy link
Owner

ratson commented Oct 25, 2017

intlSelector with key property should do the same.

@ratson ratson closed this Oct 25, 2017
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