Created
October 1, 2018 03:42
-
-
Save JeffML/f321278c0101a15fb8353f070ac7b798 to your computer and use it in GitHub Desktop.
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
import React from "react" | |
import { Query } from "react-apollo"; | |
import gql from "graphql-tag"; | |
const ExchangeRates = () => ( | |
<Query | |
query={gql` | |
{ | |
rates(currency: "USD") { | |
currency | |
rate | |
name | |
} | |
} | |
`} | |
> | |
{({ loading, error, data }) => { | |
if (loading) return <p>Loading...</p>; | |
if (error) return <p>Error :(</p>; | |
return data.rates.map(({ currency, rate, name }) => ( | |
<div key={currency}> | |
<p>{`${currency}: ${rate}(${name})`}</p> | |
</div> | |
)); | |
}} | |
</Query> | |
); | |
export default ExchangeRates; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment