Skip to content

Instantly share code, notes, and snippets.

@coryhouse
Created October 26, 2017 11:54
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 coryhouse/f21371f02f2b6f7e974a5bf904ff20d5 to your computer and use it in GitHub Desktop.
Save coryhouse/f21371f02f2b6f7e974a5bf904ff20d5 to your computer and use it in GitHub Desktop.
Example of centralizing propTypes
// You could centralize all your object shape definitions here
import PropTypes from 'prop-types';
export const Customer = PropTypes.shape({
id: PropTypes.number,
photo: PropTypes.string.isRequired,
firstName: PropTypes.string.isRequired,
middleName: PropTypes.string.isRequired,
lastName: PropTypes.string.isRequired,
isCompany: PropTypes.bool.isRequired,
companyName: PropTypes.string,
companyType: PropTypes.string,
address: PropTypes.shape( {
customerAddressId: PropTypes.number,
street: PropTypes.string.isRequired,
street2: PropTypes.string,
city: PropTypes.string.isRequired,
state: PropTypes.string.isRequired,
postal: PropTypes.string.isRequired
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment