Skip to content

Instantly share code, notes, and snippets.

@AndrewIngram
Created May 10, 2018 22:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewIngram/7e2d944d0994e54e3a71812de2bf82b9 to your computer and use it in GitHub Desktop.
Save AndrewIngram/7e2d944d0994e54e3a71812de2bf82b9 to your computer and use it in GitHub Desktop.
Simple Relay component
// @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