Created
May 18, 2018 23:40
-
-
Save kfarst/289d9686f533ddfb1df43e63cb981e93 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
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