У меня проблемы с обновлением моего приложения React с помощью react-i18next
.
У меня есть HOC, который "абстрагирует" соединение с Redux.Этот HOC выглядит так:
// This is the component I used to use, but it doesn't exist anymore in v10:
import { I18n } from "react-i18next";
export const myHOC = identifier => ({
actions,
translations,
}) => WrappedComponent => {
// connnect the WrappedComponent to Redux:
const ConnectedComponent = connect(
// generate the mapStateToProps automatically
mapStateToProps(),
actions
)
class MyConnnector extends Component {
// constructor:
constructor(props, context) {
super(props);
// Can't say why new React new Context API doesn't bring
// store (from Redux) and i18n (from react-i18next) are undefined here:
console.log(context.store, context.i18n); // undefined, undefined
}
// then render method:
render() {
// If there are translation to use...
if (translations) {
return (
// Return the I18n component with the previously ConnectedComponent as a child:
// HERE! This component doesn't exists anymore. What's the best way to replace it?
<I18n i18n={this.context.i18n} ns={[key, "commom"]}>
<ConnnectedComponent {...this.props} />
</I18n>
);
}
return <ConnectedComponent {...this.props} />
}
}
return MyConnnector;
}