@comparaonline/react-intl-hooks
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@comparaonline/react-intl-hooks

Workaround to have a React Intl Hooks

Source: https://github.com/yahoo/react-intl/issues/1224#issuecomment-449895045

Installation

This package has as peer dependencies React (^16.8) and React Intl

yarn add react-intl 

If you use TS

yarn add [--dev] @types/react-intl
yarn add @comparaonline/react-intl-hooks

Usage

import { useFormatMessage, InjectIntlContext } from '@comparaonline/react-intl-hooks';

const TestIntl = () => {
  const t = useFormatMessage();
  return (
    <div>
      { t('translation.id', { value: 'sample'}) }
    </div>
  )
}

const App = () => ( 
  <IntlProvider locale={intlLocale} key={intlLocale} messages={messages} defaultLocale='en-gb'>
    <InjectIntlContext>
      <TestIntl />
    </InjectIntlContext>
  </IntlProvider>
);

Readme

Keywords

none

Package Sidebar

Install

npm i @comparaonline/react-intl-hooks

Weekly Downloads

115

Version

0.0.1

License

none

Unpacked Size

15.6 kB

Total Files

9

Last publish

Collaborators

  • gnavarro
  • dsuarez_compa
  • pfariaz
  • ricardo.sosa
  • suarezcumare
  • fverag
  • comparaonline-dev
  • comparaonlineprivate
  • matotias
  • javierlara1989
  • smurua
  • eseceve
  • pablocompara