Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import React, { Component } from 'react';
import { Mutation } from 'urql';
const addTodo = /* ... */;
class TodoForm extends Component {
add = () => this.props.addTodo({ text: 'something!' });
render() {
if (this.props.error) {
return 'Oh no!';
}
return <button onClick={this.add}>Add something!</button>
}
}
const WithMutation = () => (
<Mutation query={addTodo}>
{({ error, executeMutation }) => <TodoForm error={error} addTodo={executeMutation} />
</Mutation>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.