Skip to content

Instantly share code, notes, and snippets.

@giuseppeg
Last active August 17, 2018 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giuseppeg/80d0fceff2391b4fb822dd6dcb4a9955 to your computer and use it in GitHub Desktop.
Save giuseppeg/80d0fceff2391b4fb822dd6dcb4a9955 to your computer and use it in GitHub Desktop.
/* @flow */
import React from 'react'
import messages from '../messages'
import { injectIntl } from 'react-intl'
import type { IntlShape } from 'react-intl'
type Props = {|
children: React.Node,
intl: IntlShape,
|}
export class Foo extends React.Component<Props> {
render() {
const { formatMessage } = this.props.intl
return (
<React.Fragment>
<h1>{formatMessage(messages.something)}</h1>
{this.props.children}
</React.Fragment>
)
}
}
export default injectIntl(Foo)
/* @flow */
import { IntlProvider } from 'react-intl'
import type { IntlShape } from 'react-intl'
const intlProvider = new IntlProvider({ locale: 'en' }, {})
export const intl: IntlShape = intlProvider.getChildContext().intl
export const intlWrapped = (name: string): string => `InjectIntl(${name})`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment