Skip to content

Instantly share code, notes, and snippets.

@kfarst
Created May 18, 2018 23:40
Show Gist options
  • Save kfarst/289d9686f533ddfb1df43e63cb981e93 to your computer and use it in GitHub Desktop.
Save kfarst/289d9686f533ddfb1df43e63cb981e93 to your computer and use it in GitHub Desktop.
class TodoList extends React.Component {
render() {
return (
<QueryRenderer
environment={environment}
query={graphql`
query TodoListQuery {
list {
# Specify any fields required by '<TodoList>' itself.
title
# Include a reference to the fragment from the child component.
todoItems {
...TodoItem_item
}
}
}
`}
render={({error, props}) => {
if (error) {
<div>{error.message}</div>;
} else if (props) {
<Text>{props.list.title}</Text>
{props.list.todoItems.map(item => <TodoItem item={item} />)}
} else {
<div>Loading</div>;
}
}}
/>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment