Skip to content

Instantly share code, notes, and snippets.

@acomito
Created July 20, 2020 18:50
Show Gist options
  • Save acomito/9fb775ecce718f75659351eb2ea7ae94 to your computer and use it in GitHub Desktop.
Save acomito/9fb775ecce718f75659351eb2ea7ae94 to your computer and use it in GitHub Desktop.
import React from 'react';
import MY_MUTATION from 'ApolloClient/Mutations/myMutation.js'
import { graphql } from 'react-apollo'
class MyFunctionComponent extends React.PureComponent {
handleOnClick = async () => {
await this.props.myMutation({})
}
render() {
return <button onClick={this.handleOnClick}>Click Me</Button>
}
}
export default graphql(MY_MUTATION, { name: 'myMutation' })(MyFunctionComponent) // will put the mutation into this.props
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment