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

1.0.0-beta.2 • Public • Published

Intl-React

@calmdownval/intl bindings for React.

Installation

# NPM
npm i @calmdownval/intl @calmdownval/intl-react

# Yarn
yarn add @calmdownval/intl @calmdownval/intl-react

Both packages already contain TypeScript declarations.

Usage

First add a top-level provider to load a locale:

import { IntlProvider } from '@calmdownval/intl-preact';
import React from 'react';

export const App = () => (
  <IntlProvider url='/path/to/locale.json'>
    ...app contents
  </IntlProvider>
);

Then use the intl hook within components:

import { useIntl } from '@calmdownval/intl-preact';
import React from 'react';

export const SubmitButton = () => {
  const { t } = useIntl();
  return (
    <button type='submit'>
      {t('form.submit')}
    </button>
  );
};

Readme

Keywords

none

Package Sidebar

Install

npm i @calmdownval/intl-react

Weekly Downloads

1

Version

1.0.0-beta.2

License

ISC

Unpacked Size

22.3 kB

Total Files

10

Last publish

Collaborators

  • calmdownval