Skip to content
This repository has been archived by the owner on Sep 20, 2020. It is now read-only.

Latest commit

 

History

History
31 lines (23 loc) · 1.3 KB

i18nextprovider.md

File metadata and controls

31 lines (23 loc) · 1.3 KB

I18nextProvider

The provider is responsible to pass the i18next instance passed in by props down to all the translate hocs or I18n using react context.

import React from 'react';
import ReactDOM from 'react-dom';
import { I18nextProvider } from 'react-i18next';

import App from './App'; // your entry page
import i18n from './i18n'; // initialized i18next instance

ReactDOM.render(
  <I18nextProvider i18n={ i18n }>
    <App />
  </I18nextProvider>,
  document.getElementById('app')
);

For the i18n instance have a look at the i18next instance page.

The I18nextProvider props:

name type (default) description
i18n object (undefined) pass i18next instance the provider will pass it down to translation components by context
defaultNS string (undefined) optionally pass down a default namespace to your translate HOC, I18n render prop (without having to specify it there)
initialI18nStore object (undefined) pass in initial translations (useful for serverside rendering)
initialLanguage string (undefined) pass in initial language (useful for serverside rendering)