Skip to content

Instantly share code, notes, and snippets.

@himanshu-dixit
Created December 15, 2018 13:37
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 himanshu-dixit/f3a2fa57b677680db2c43ba8ddeaa4b0 to your computer and use it in GitHub Desktop.
Save himanshu-dixit/f3a2fa57b677680db2c43ba8ddeaa4b0 to your computer and use it in GitHub Desktop.
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