Created
June 5, 2017 18:50
-
-
Save mtomcal/f23696c22987b6e6031e4e68a0572a07 to your computer and use it in GitHub Desktop.
Block Prop Types
This file contains hidden or 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
{ | |
const { string, object, arrayOf, func } = PropTypes; | |
Component.propTypes = { | |
value: string, | |
starships: arrayOf(object).isRequired, | |
name: string, | |
onChange: func.isRequired, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.