component did mount mutation graphql

Solutions on MaxInterview for component did mount mutation graphql by the best coders in the world

showing results for - "component did mount mutation graphql"
Brittany
14 Feb 2019
1import React from 'react';
2import { Mutation } from 'react-apollo';
3
4class DoMutation extends React.Component {
5  componentDidMount() {
6    const { mutate } = this.props;
7    mutate();
8  };
9
10  render() {
11    return null;
12  };
13};
14
15const MutationOnMount = ({ children, ...other }) => {
16  return (
17    <Mutation
18      {...other}
19    >
20      {(mutate, { data, loading, error }) => (
21        <React.Fragment>
22          <DoMutation mutate={mutate} />
23          { children && children(mutate, { data, loading, error }) }
24        </React.Fragment>
25      )}
26    </Mutation>
27  )
28};
29
30
31export default MutationOnMount;