-
Notifications
You must be signed in to change notification settings - Fork 43
Remove props.key workaround #7
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 am also experience trouble with this. If I connect a component to state.intl.locale the componentWillReceiveProps (nextProps) {
if (this.props.intLang !== nextProps.intLang) {
console.log('page locale', this.props.intLang, ' => ', nextProps.intLang)
}
} But if I remove the
|
@gerhardsletten From my test, I don't experience this problem, so I am planning to remove this hack and use the |
Sorry, been some time since I touched this, but in this use-case we also kept an preference-reducer, so we connected our views to it to re-render / load localized content in the newly chosen language. It was a stack with many players, so it could be some other dependency which made the componentWillReceiveProps check not work. |
A custom |
Hi @ratson, removing the key broke our app. Is this a good workaround (or is there a simpler one?) to the problem where changing locale does not re-render components? import { connect } from 'react-redux'; import { IntlProvider } from 'react-intl'; function defaultSelector(state) { return { ...state.intl, key: state.intl.locale, }; } const mapStateToProps = (state, { intlSelector = defaultSelector }) => intlSelector(state); export default connect(mapStateToProps)(IntlProvider); And then use it like: import { Provider } from 'react-redux'; import CustomIntlProvider from './i18n/customIntlProvider'; import RoutedApp from './RoutedApp'; .... render() { return ( <Provider store={store}> <CustomIntlProvider> <RoutedApp /> </CustomIntlProvider> </Provider> ); } |
Pull request #6 introduced a workaround for facebook/react#2517.
Should be removed when React fixed it.
The text was updated successfully, but these errors were encountered: