Last active
April 10, 2017 15:52
-
-
Save skovhus/a8f7a10e0b7fabba426039e0a26c36fb to your computer and use it in GitHub Desktop.
PropTypes to Flow blog post
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
/* 1) Using good old PropTypes */ | |
function Button({ message }) => | |
<button>{message}</button>; | |
Button.propTypes = { | |
message: PropTypes.oneOfType([ | |
PropTypes.string, | |
PropTypes.number, | |
PropTypes.instanceOf(Message) | |
]).isRequired, | |
}; | |
/* 2) Using Flow annotations */ | |
type Props = { | |
message: string | number | Message, | |
}; | |
function Button({ message } : Props) => | |
<button>{message}</button>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment