Last active
October 14, 2017 02:26
-
-
Save burgwyn/d0ce1e4877d7c7e81604e0ae29db9cab to your computer and use it in GitHub Desktop.
PropTypes and DefaultProps - Good Example
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 propTypes from ‘prop-types’; | |
const propTypes = { | |
findDelay: PropTypes.number, | |
columns: PropTypes.array, | |
loadCollapsed: PropTypes.bool, | |
tableHeight: PropTypes.number, | |
rowHeight: PropTypes.number, | |
defaultColWidth: PropTypes.number, | |
}; | |
const defaultProps = { | |
findDelay: 500, | |
columns: [], | |
loadCollapsed: false, | |
tableHeight: 500, | |
rowHeight: 96, | |
defaultColWidth: 0 | |
}; | |
export default class YourComponent extends React.Component { | |
// Your code | |
} | |
YourComponent.propTypes = propTypes; | |
YourComponent.defaultProps = defaultProps; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment