Skip to content

Instantly share code, notes, and snippets.

@ctwhome
Forked from efernandesng/component.js
Created October 21, 2017 15:02
Show Gist options
  • Save ctwhome/ebb7105b0c3604021636d88e30533d7c to your computer and use it in GitHub Desktop.
Save ctwhome/ebb7105b0c3604021636d88e30533d7c to your computer and use it in GitHub Desktop.
react-intl injectIntl decorator
import React, {Component, PropTypes} from 'react';
import {intlShape} from 'react-intl';
import {injectIntl} from './decorator';
@injectIntl()
class Xpto extends Component {
static propTypes = {
intl: intlShape.isRequired
};
render() {
const {intl} = this.props;
return <div>Locale:{intl.locale}</div>;
}
}
import {injectIntl as inject} from 'react-intl';
export const injectIntl = options => target=> {
return inject(target, options);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment