Created
February 13, 2018 20:15
-
-
Save charlypoly/5ffb5f7d5d0c744612404ffdc802cd0a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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