Skip to content

Commit

Permalink
Merge pull request #118 from relay-tools/usemutation-environment
Browse files Browse the repository at this point in the history
replaced useContext with useRelayEnvironment in useMutation
  • Loading branch information
morrys authored Oct 4, 2020
2 parents 2b2e325 + 3ce49e3 commit 696aa2f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/useMutation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*eslint-disable */
import * as invariant from 'fbjs/lib/invariant';
import * as React from 'react';
import { ReactRelayContext } from './ReactRelayContext';
import { Environment, MutationParameters, commitMutation } from 'relay-runtime';
import useMounted from '@restart/hooks/useMounted';
import {
Expand All @@ -11,7 +10,8 @@ import {
Mutate,
MutationProps,
} from './RelayHooksType';
const { useCallback, useContext, useState } = React;
import { useRelayEnvironment } from './useRelayEnvironment';
const { useCallback, useState } = React;

export function useMutation<T extends MutationParameters>(
mutation: MutationNode<T>,
Expand All @@ -27,8 +27,8 @@ export function useMutation<T extends MutationParameters>(

const isMounted = useMounted();

const relayContext: any = useContext(ReactRelayContext);
const resolvedEnvironment = environment || relayContext.environment;
const relayEnvironment = useRelayEnvironment();
const resolvedEnvironment = environment || relayEnvironment;
const {
configs,
variables,
Expand Down

0 comments on commit 696aa2f

Please sign in to comment.