react-intl-inject
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

react-intl-inject

react-intl helper, can translate props easily

Installation

Make sure react-intl is installed, it is required as a peer dependency

npm i react-intl

Then install as usual

npm i react-intl-inject

Usage

Suppose you need to translate a prop, for instance the value of a submit button.

import React, { Component } from 'react'
import InjectIntl from 'react-intl-inject'
 
class MyComponent extends Component {
  render () {
    return (
      <InjectIntl>
        {({ intl }) => (
          <button
            type='submit'
            value={intl.formatMessage({ id: 'enter.submit' })}
          />
        )}
      </InjectIntl>
    )
  }
}

See also this Stack Overflow question.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i react-intl-inject

Weekly Downloads

3

Version

0.1.2

License

MIT

Unpacked Size

4.47 kB

Total Files

7

Last publish

Collaborators

  • fibo