Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@chris001177
Created June 25, 2019 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris001177/40aea5352ceb8831f0ce8e4a30fa8c98 to your computer and use it in GitHub Desktop.
Save chris001177/40aea5352ceb8831f0ce8e4a30fa8c98 to your computer and use it in GitHub Desktop.
import React from 'react';
import { Query } from 'urql';
const getTodos = `
query GetTodos {
todos(limit: 10) {
id
text
isDone
}
}
`;
const TodoList = () => {
<Query query={getTodos}>
{({ executeQuery, data }) => {
if (!data) {
return null;
}
return (
<div>
<ul>
{data.todos.map(({ id, text }) => (
<li key={id}>{text}</li>
))}
</ul>
<button
onClick={() => executeQuery({ requestPolicy: 'network-only' })}
>
Refresh
</button>
</div>
);
}}
</Query>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment