Skip to content

Instantly share code, notes, and snippets.

@himanshu-dixit
Created December 15, 2018 13:38
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/3379e74198ee2d15de83309fbb1d669e to your computer and use it in GitHub Desktop.
Save himanshu-dixit/3379e74198ee2d15de83309fbb1d669e to your computer and use it in GitHub Desktop.
import React, {Component} from 'react';
import {Mutation} from 'react-apollo';
import {updateTodo, getTodos} from '../../Queries';
class UpdateToDo extends Component {
constructor(props) {
super(props);
this.state = {
id: this.props.todo_id
}
}
updateTodo(update_to_do) {
update_to_do({variables: this.state, refetchQueries: [{query: getTodos}]});
}
render() {
return (
<Mutation mutation={updateTodo}>
{(update_to_do) => (
<div className="update" onClick={() => {
this.updateTodo(update_to_do);
}
}>✓</div>
)}
</Mutation>
);
}
}
export default UpdateToDo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment