Skip to content

Instantly share code, notes, and snippets.

@mikebridge
Created March 22, 2017 15:43
Show Gist options
  • Save mikebridge/728b3263aa878439b1d84876d23bdada to your computer and use it in GitHub Desktop.
Save mikebridge/728b3263aa878439b1d84876d23bdada to your computer and use it in GitHub Desktop.
Typescript component using react-intl
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;
@soulmachine
Copy link

👍

@not-only-code
Copy link

not-only-code commented Mar 2, 2018

And render this <ExampleComponent />, works for you without passing an intl prop?

@kaimiyang
Copy link

thank you!

@smaslovv
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment