Created
December 15, 2018 13:37
-
-
Save himanshu-dixit/f3a2fa57b677680db2c43ba8ddeaa4b0 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 {Mutation} from 'react-apollo'; | |
import {deleteTodo, getTodos} from '../../Queries'; | |
class DeleteTodos extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
id: this.props.todo_id | |
} | |
} | |
deletetodo(delete_to_do) { | |
delete_to_do({ variables: this.state, refetchQueries: [{ query: getTodos }] }); | |
} | |
render() { | |
return ( | |
<Mutation mutation={deleteTodo}> | |
{(delete_to_do) => ( | |
<div className="delete" onClick={() => { | |
this.deletetodo(delete_to_do); | |
} | |
} >x</div> | |
)} | |
</Mutation> | |
); | |
} | |
} | |
export default DeleteTodos; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment