Last active
December 15, 2018 13:30
-
-
Save himanshu-dixit/ad1f1c59894c8144b33408c8485927a6 to your computer and use it in GitHub Desktop.
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 { Query} from 'react-apollo'; | |
import {getTodos} from '../../Queries'; | |
import DeleteTodos from "./DeleteTodos"; | |
import UpdateToDo from "./UpdateToDo"; | |
class ListAllTodos extends Component { | |
render() { | |
return ( | |
<Query query={getTodos}> | |
{({loading, error, data}) => { | |
if (loading) return 'Loading...'; | |
if (error) return `Error! ${error.message}`; | |
return data.todo.map((todo) => ( | |
<div className={todo.completed?"task "+"completed":"task"}>{todo.task} | |
<DeleteTodos todo_id={todo.id}/> | |
<UpdateToDo todo_id={todo.id}/> | |
</div> | |
)); | |
}} | |
</Query> | |
); | |
} | |
} | |
export default ListAllTodos; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment