Created
October 12, 2015 17:57
-
-
Save aaronshaf/547e520de2cfa2f38b1b to your computer and use it in GitHub Desktop.
annotating a stateless function component in flowtype
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
/* @flow */ | |
import React from 'react' | |
type QuoteProps = { | |
message: string, | |
quote: string, | |
name: string, | |
photoUrl: string, | |
photoAlt: string | |
} | |
export default ({ | |
message, | |
quote, | |
name, | |
photoUrl, | |
photoAlt | |
}: QuoteProps): ReactElement => ( | |
<div className='Quote'> | |
<div className='Quote-message'> | |
{message} | |
</div> | |
<div className='Quote-quote'> | |
<q>{quote}</q> | |
<div>— <cite>{name}</cite></div> | |
</div> | |
<div className='Quote-image-container'> | |
<img | |
className='Quote-image' | |
src={photoUrl} | |
alt={photoAlt} | |
/> | |
</div> | |
</div> | |
) |
For the record this is out of date now and visitors should look elsewhere. Potential good starting point here: https://medium.com/flow-type/even-better-support-for-react-in-flow-25b0a3485627
Another starting point: https://flow.org/en/docs/react/components/#toc-stateless-functional-components
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍