Skip to content

Instantly share code, notes, and snippets.

@mtomcal
Created June 5, 2017 18:50
Show Gist options
  • Save mtomcal/f23696c22987b6e6031e4e68a0572a07 to your computer and use it in GitHub Desktop.
Save mtomcal/f23696c22987b6e6031e4e68a0572a07 to your computer and use it in GitHub Desktop.
Block Prop Types
{
const { string, object, arrayOf, func } = PropTypes;
Component.propTypes = {
value: string,
starships: arrayOf(object).isRequired,
name: string,
onChange: func.isRequired,
};
}
@mtomcal
Copy link
Author

mtomcal commented Jun 5, 2017

My reasoning for this is I am using AirBnB Eslint rules and I may not use PropTypes.object or PropTypes.array in the first level of the propTypes. I therefore shorten it by using a block to scope out the const destructure of string, object, arrayOf, func and then use these shortened versions like Flow types or Typescript types in a way. Therefore we don't (hopefully) trample anything with this methodology since it's inside a block. Let me know any thoughts or suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment