Skip to content

Instantly share code, notes, and snippets.

@hurali97
Created July 20, 2019 22:09
Show Gist options
  • Save hurali97/fecb6fdf098cccc4d6e092d19de07629 to your computer and use it in GitHub Desktop.
Save hurali97/fecb6fdf098cccc4d6e092d19de07629 to your computer and use it in GitHub Desktop.
Names
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