react & i18next, why do i need react-i18next

Viewed 378

I am new to i18next and I dont really understand why there is a need to use react-i18next when playing with react.

Using an external library like moment.js in my component i do : const date = moment(this.state.date)

Can I do the something like below with i18next :

import i18next from 'i18next';

const translated = () => (
 <h1>{i18next.t('title')}</h1>
)

Thanks

1 Answers

sure you can directly use i18next. react-i18next is only some optimization to use it in react -> eg. rerender on language change, or dynamic load of the namespaces using the hoc or render prop. Or the Trans component which allows you to nest react components into translations. But there is no magic, like there is no magic in jquery-i18next or vue-i18next -> it just simplifies your task.

Related