Created
October 26, 2017 11:54
-
-
Save coryhouse/f21371f02f2b6f7e974a5bf904ff20d5 to your computer and use it in GitHub Desktop.
Example of centralizing propTypes
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
// 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