Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 451 Bytes

withT.md

File metadata and controls

19 lines (16 loc) · 451 Bytes

withT

React higher order component that injects t translation function and T state of the <Provider> into the props of your component.

const Demo = ({t, T}) => {
  return (
    <div>
      {t('Hello')}, user! {t('welcome')}
      <br />
      <button onClick={() => T.setLocale('en')}>en</button>
      <button onClick={() => T.setLocale('fr')}>fr</button>
    </div>
  );
};

export default withT(Demo);