Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@burgwyn
Last active October 14, 2017 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burgwyn/d0ce1e4877d7c7e81604e0ae29db9cab to your computer and use it in GitHub Desktop.
Save burgwyn/d0ce1e4877d7c7e81604e0ae29db9cab to your computer and use it in GitHub Desktop.
PropTypes and DefaultProps - Good Example
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