import { useMutation } from '@apollo/react-hooks';
      
      const [triggerMutation, { data, loading, error }] = useMutation(graphqlMutation);
      if (loading) return 'Loading...';
      if (error) return `Error: ${error.message}`;
        return (
          <div>
            <form
              onSubmit={e => {
                e.preventDefault();
                triggerMutation({ variables: { variableName: variableValue } });
                input.value = '';
              }}
            >
            </form>
          </div>
        );
      }
      Javascript language logo

      useMutation with variable

      My JavaScript recipes

      useMutation react hook with variables

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.