Created
March 22, 2017 15:43
-
-
Save mikebridge/728b3263aa878439b1d84876d23bdada to your computer and use it in GitHub Desktop.
Typescript component using react-intl
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 * as React from "react"; | |
import SelectField from "material-ui/SelectField"; | |
import { intlShape, injectIntl, FormattedMessage, InjectedIntlProps } from "react-intl"; | |
interface IExampleProps { | |
// ... | |
} | |
class ExampleComponentWrapped extends React.Component<IExampleProps & InjectedIntlProps, {}> { | |
static propTypes: React.ValidationMap<any> = { | |
intl: intlShape.isRequired | |
}; | |
public render(): JSX.Element { | |
return ( | |
<SelectField floatingLabelText={this.props.intl.formatMessage({id: "hello_world"})} /> | |
); | |
} | |
} | |
const ExampleComponent = injectIntl(ExampleComponentWrapped); | |
export default ExampleComponent; |
And render this <ExampleComponent />
, works for you without passing an intl
prop?
thank you!
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍