Created
July 20, 2019 22:09
-
-
Save hurali97/fecb6fdf098cccc4d6e092d19de07629 to your computer and use it in GitHub Desktop.
Names
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
import React, { Component } from 'react'; | |
import { GET_NAMES } from './queries.js' | |
import { Query } from 'react-apollo'; | |
class Names extends Component { | |
render() { | |
return ( | |
<Query query={GET_NAMES}> | |
{({ loading, error, data }) => { | |
if (loading) return <div>Loading...</div>; | |
if (error) return <div>Error :(</div>; | |
return data.getnames.map(({ name }, i) => <h3 key={i} > {name} </h3> ) | |
}} | |
</Query> | |
); | |
} | |
} | |
export default Names; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment