withI18n (v9)

Was introduced in v8.0.0. Not available in older versions.

withI18n is a basic higher order component which passes mainly the t function down to the wrapped component.

import React, { Component } from "react";
import { withI18n } from "react-i18next";

class MyComponent extends Component {
  render() {
    const { t } = this.props;

    return <h2>{t('Welcome to React')}</h2>;
  }
}
export default withI18n()(MyComponent);

Last updated