Skip to content

Instantly share code, notes, and snippets.

@coryhouse
Last active November 17, 2017 14:14
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/5cea28dc6639963d26803f84e5a14fcb to your computer and use it in GitHub Desktop.
Save coryhouse/5cea28dc6639963d26803f84e5a14fcb to your computer and use it in GitHub Desktop.
Centralized propTypes declaration
// types/index.js
import { shape, number, string, oneOf } from 'prop-types';
export const userType = shape({
id: number,
firstName: string.isRequired,
lastName: string.isRequired,
company: string,
role: oneOf(['user', 'author']),
address: shape({
id: number.isRequired,
street: string.isRequired,
street2: string,
city: string.isRequired,
state: string.isRequired,
postal: number.isRequired
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment