-
Notifications
You must be signed in to change notification settings - Fork 1.4k
FormattedMessage vs formatMessage - re-rendering ? #585
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
Comments
|
I just realized you're using a React element inside of an attribute named So for this specific case you're correctly using |
With the previous example, if a class |
I have another case where a component, wrapped by injectIntl, renders several of these links:
I replaced one of these links with:
When changing the locale, only strings from Do you have any idea on what could happen ? Packages:
|
Maybe you're hitting this issue with React and |
Oh sorry I missed it, thank you for the link. The workaround with |
@amangeot did that fix the issue? (I really hope this is fixed in React 16) |
@ericf yes adding However it can add another issue as it unmounts / mounts all components. This triggers data fetching from Components' Another issue for my project is that I use In order to avoid re-mounting components like this map or data-fetchers, I tried to apply the same logic but at a deeper level with a HOC like this one:
For example, the following structure is to pick a time by dragging a div
The position of The problem is @ericf do you see a way to move the |
Other things to look at is using injectIntl around the connected components, having the app extend Component instead of PureComponent. Do you expect users to change their locale often? |
Sorry, I missed your message. Setting |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I have been using
formatMessage
, wrapping my components withinjectIntl
. This way when the locale changes, the component updates itself and its message translations:<SomeLink to='/login' title={this.props.intl.formatMessage(login)} />
I just tried moving to
FormattedMessage
, removinginjectIntl
, but this way the component doesn't re-render when the locale changes:<SomeLink to='/login' title={<FormattedMessage {...login} />} />
Is it possible to use
FormattedMessage
withoutinjectIntl
and still having theFormattedMessage
update themselves when locale changes ?This is how I setup
IntlProvider
in my redux app:The text was updated successfully, but these errors were encountered: