Skip to content

Instantly share code, notes, and snippets.

@adhithiravi
Last active April 30, 2018 21:40
Show Gist options
  • Save adhithiravi/5345c3ca2d1c82d64bd78f9d4dcebf48 to your computer and use it in GitHub Desktop.
Save adhithiravi/5345c3ca2d1c82d64bd78f9d4dcebf48 to your computer and use it in GitHub Desktop.
Defining PropTypes for a component example.
import PropTypes from 'prop-types'
export default class MyComponent extends React.Component {
render() {
// Render Something
}
}
// You can declare that a prop is a specific JS type.
MyComponent.propTypes = {
text: PropTypes.string.isRequired,
content: PropTypes.array.isRequired,
onPress: PropTypes.func.isRequired,
size: PropTypes.number.isRequired,
styles: PropTypes.object.isRequired,
isReady: PropTypes.bool.isRequired,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment