Skip to content

Instantly share code, notes, and snippets.

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