Skip to content

Instantly share code, notes, and snippets.

@koss-lebedev
Last active May 24, 2018 13:33
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 koss-lebedev/106938164be5c5dd7a36f744972afef8 to your computer and use it in GitHub Desktop.
Save koss-lebedev/106938164be5c5dd7a36f744972afef8 to your computer and use it in GitHub Desktop.
// @flow
const SIZE = Object.freeze({
LARGE: "large",
MEDIUM: "medium",
SMALL: "small"
})
type ISize = $Values<typeof SIZE>
// props type for Avatar component
type IProps = {|
size: ISize,
|}
const Avatar = (props: IProps) => (
// ...component details are omitted
)
// this works
<Avatar size={SIZE.LARGE} />
// this works as well, althouh it's discouraged
<Avatar size="large" />
// this gives an error
<Avatar size="larg" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment