-
-
Save ctwhome/ebb7105b0c3604021636d88e30533d7c to your computer and use it in GitHub Desktop.
react-intl injectIntl decorator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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