Created
May 10, 2018 22:25
-
-
Save AndrewIngram/7e2d944d0994e54e3a71812de2bf82b9 to your computer and use it in GitHub Desktop.
Simple Relay component
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
// @flow | |
import { PureComponent } from 'react'; | |
import { graphql, createFragmentContainer } from 'react-relay'; | |
import FormatCurrency from '@zego/components/FormatCurrency'; | |
import { type Price_price } from './__generated__/Price_price.graphql'; | |
type Props = { | |
price: Price_price, | |
precision?: number, | |
}; | |
class Price extends PureComponent<Props> { | |
render() { | |
const { price, precision } = this.props; | |
return ( | |
<FormatCurrency | |
currency={price.currency.isoCode} | |
value={price.value} | |
precision={precision} /> | |
); | |
} | |
} | |
export default createFragmentContainer( | |
Price, | |
graphql` | |
fragment Price_price on Price { | |
value | |
currency { | |
isoCode | |
} | |
} | |
` | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment