withNamespaces (v9)
Last updated
Last updated
The withNamespaces is responsible for passing the to your component. It enables all the translation functionality provided by i18next. Further, it asserts your component gets re-rendered on language change or changes to the translation catalog itself (loaded translations).
To help you using TypeScript and the @withNamespaces decorator here is a trival example:
Most time you like to change those values for every component.
Set those on i18next init:
option
type (default)
description
wait
boolean (false)
In most cases you like to set this to true. If not handling not ready by evaluating tReady.
nsMode
string ('default')
default: namespaces will be loaded an the first will be set as default or
fallback: namespaces will be used as fallbacks used in order provided
innerRef
function or object (undefined)
either pass in a object React.createRef or a ref function like (c) => this.myRef = c;
bindI18n
string ('languageChanged loaded')
which events trigger a rerender, can be set to false or string of events
bindStore
string ('added removed')
which events on store trigger a rerender, can be set to false or string of events
omitBoundRerenders
boolean (true)
Does not trigger rerenders while state not ready - avoiding unneeded renders on init
i18n
object (undefined)
usePureComponent
boolean (false)
use shallowEqual on props change if set to true
name
type (default)
description
i18n
object (undefined)
pass i18next instance by props instead of having it on context
initialI18nStore
object (undefined)
initialLanguage
object (undefined)
If not using the this hoc should be nested inside a . Alternatively you can pass the i18next instance via prop i18n
.
assert all provided namespaces are loaded before rendering the component (can be set too)
pass i18next via options (useful for
pass in initial translations (useful for )
pass in initial language (useful for )