Skip to content

Instantly share code, notes, and snippets.

@siddhant1
Created March 20, 2019 10:08
Show Gist options
  • Save siddhant1/8fd10ddd8aa364fcba1c5da269faa915 to your computer and use it in GitHub Desktop.
Save siddhant1/8fd10ddd8aa364fcba1c5da269faa915 to your computer and use it in GitHub Desktop.
import React, { Component } from "react";
import { Mutation } from "react-apollo";
import { DELETE_TODO, GET_INCOMPLETE_TODOS, GET_ALL_TODOS } from "../queries";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faTimes } from "@fortawesome/free-solid-svg-icons";
import { Button } from "react-bootstrap";
class DeleteTodo extends Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return (
<Mutation
mutation={DELETE_TODO}
variables={this.props}
refetchQueries={[
{ query: GET_INCOMPLETE_TODOS },
{ query: GET_ALL_TODOS }
]}
>
{(delete_todos, { data }) => (
<Button
onClick={e => {
e.preventDefault();
delete_todos();
}}
>
<FontAwesomeIcon icon={faTimes} style={{ color: "red" }} />
</Button>
)}
</Mutation>
);
}
}
export default DeleteTodo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment