react-i18next
react-i18next copied to clipboard
Set component prop?
Any pointers on when I need something like below?
I'm having trouble with the async aspect on i18next when I need to set a component prop. i18next is sometimes not yet ready before I set this prop. Or is this outside the scope of this repo?
i18n.js
import i18n from 'i18next/lib';
import XHR from 'i18next-xhr-backend/lib';
i18n
.use(XHR)
.init({
debug: true,
lang: 'nl',
fallbackLng: 'nl',
defaultNS: 'translation',
interpolation: {
escapeValue: false
}
});
export default i18n;
form.js
import i18next from './i18n.js'; // instance
export default React.createClass({
render() {
<Input
name="name"
placeholder={i18next.t('placeholder')}
/>
};
});
basically you don't use react-i18next. react-i18next solves this when you use the hoc (higher order component) -> https://github.com/i18next/react-i18next#translate-hoc
can this be closed?