Skip to content

Instantly share code, notes, and snippets.

@mb8z
Last active October 2, 2018 14:53
Show Gist options
  • Save mb8z/303cee29e0b1b19fdd96b5efc39e98dd to your computer and use it in GitHub Desktop.
Save mb8z/303cee29e0b1b19fdd96b5efc39e98dd to your computer and use it in GitHub Desktop.
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