const DeleteItemMutation = ({ id, render }) => (
<Mutation mutation={DELETE_ITEM_MUTATION}>
{mutate =>
render({
deleteItem: id => {
mutate({
variables: { id },
// optimisticResponse
// update
});
},
})
}
</Mutation>
);
const Item = ({ id }) => (
<DeleteItemMutation
id={id}
render={({ deleteItem }) => (
<li>
<button onClick={() => deleteItem()}>Delete</button>
</li>
)}
/>
);
Last active
March 30, 2018 05:35
-
-
Save EddiG/705d06d283689cdde107576660bb3dd2 to your computer and use it in GitHub Desktop.
That is how you can reuse the Mutation component from React Apollo client
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment