Skip to content

Instantly share code, notes, and snippets.

@skovhus
Last active April 10, 2017 15:52
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 skovhus/a8f7a10e0b7fabba426039e0a26c36fb to your computer and use it in GitHub Desktop.
Save skovhus/a8f7a10e0b7fabba426039e0a26c36fb to your computer and use it in GitHub Desktop.
PropTypes to Flow blog post
/* 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