Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

apollo client mutation without component

// react-apollo includes two HOCs called graphql() and withApollo() that can be used to accomplish this.
// This example takes the withApollo() HOC approach

import React, { Component } from "react";
import { DO_MUTATION } from "./mutations";
import { withApollo } from "react-apollo";

import SomeLibrary from "SomeLibrary";

export class MyComponent extends Component {
    render() {
        return (
            <Button
                onPress={() => {
                    SomeLibrary.addListener(this.listenerHandler);
                }}
            />
        );
    }

    listenerHandler = () => {
        this.props.client.mutate({
            mutation: DO_MUTATION,
            variables: {
                some_var: "some_val",
            },
        });
    };
}
export default withApollo(MyComponent);
Comment

PREVIOUS NEXT
Code Example
Javascript :: postman environment variable 
Javascript :: slimscroll javascript 
Javascript :: quasar $t i18n 
Javascript :: asynchronous function using function constructor 
Javascript :: array.filter in javascript 
Javascript :: promise javascript 
Javascript :: currency conversion to locale string js 
Javascript :: inline null check javascript 
Javascript :: spam system discord.js 
Javascript :: keep value after refresh javascript 
Javascript :: await the end of subscribe angular 
Javascript :: Origin http://localhost:3002 is not allowed by Access-Control-Allow-Origin. 
Javascript :: javascript number to string 
Javascript :: get all database react native 
Javascript :: routes in angular 
Javascript :: react split 
Javascript :: local reference in angular 
Javascript :: strict equality operator 
Javascript :: how to split an array javascript 
Javascript :: javascript sort strings of object 
Javascript :: css using inline styles 
Javascript :: reduce in javascript 
Javascript :: polyfill for call 
Javascript :: javascript recursion 
Javascript :: devtool google 
Javascript :: console log on html 
Javascript :: js background color 
Javascript :: JavaScript querySelector - By class 
Javascript :: do while in js 
Javascript :: node js serve pdf file 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =