Closed mrlubos closed 6 years ago
Provider enables i18n instance in react context. Hoc pass down t
function from i18n to component.
Beside that i don't know why the linter is complaining...there is no double import in one file.
@jamuhl I assume it's because I call import { translate } from 'react-i18next';
in 2 places or call it, didn't explore further. Is my syntax correct then? Once I turned off the linter rule, everything works as expected, although I should be able to access the t()
method from every child component without importing translate again and again, no?
no...you need to use the hoc on every component
the linter should not complain...at least not if using webpack and file per component...
depends on your build process
Awesome, thanks for explaining!
Hey,
Wanted to ask if this is a correct usage of react-i18next as my linter was warning me about duplicate imports.
ComponentTwo is a child of ComponentOne, but not the first child.
The whole app is rendered like so.
I understand the provider should make the
t()
method available in every child component, correct? However, neitherthis.props
northis.context
inrender()
method of ComponentTwo included this function. Thank you!