Last active
October 2, 2018 14:53
-
-
Save mb8z/303cee29e0b1b19fdd96b5efc39e98dd to your computer and use it in GitHub Desktop.
This file contains hidden or 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 from 'react'; | |
import { injectIntl } from 'react-intl'; | |
const withIntl = (WrappedComponent) => { | |
const Component = injectIntl((props) => { | |
const { intl } = props; | |
// For shorter syntax - similar to `react-i18n` | |
const t = (id, values) => intl.formatMessage({ id }, values); | |
return ( | |
<WrappedComponent {...props} t={t} /> | |
); | |
}); | |
return Component; | |
}; | |
export default withIntl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment