Skip to content

Instantly share code, notes, and snippets.

@charlypoly
Created February 13, 2018 20:15
Show Gist options
  • Save charlypoly/5ffb5f7d5d0c744612404ffdc802cd0a to your computer and use it in GitHub Desktop.
Save charlypoly/5ffb5f7d5d0c744612404ffdc802cd0a to your computer and use it in GitHub Desktop.
// without TypeScript
import PropTypes from 'prop-types';
class Greeting extends React.Component {
render() {
return (
<h1>Hello, {this.props.name}</h1>
);
}
}
Greeting.propTypes = {
name: PropTypes.string
};
// With TypeScript (no 'prop-types' import needed, and no config)
type Props = { name: string };
class Greeting extends React.Component<Props> {
render() {
return (
<h1>Hello, {this.props.name}</h1>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment