Skip to content

Commit

Permalink
Deinjectify useLazyLoadQuery
Browse files Browse the repository at this point in the history
Reviewed By: josephsavona

Differential Revision: D37252240

fbshipit-source-id: 20b64ffb3322bd35c8911e0ae40ce672fa8ee784
  • Loading branch information
davidmccabe authored and facebook-github-bot committed Jun 18, 2022
1 parent 1a5e38e commit 201438e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
2 changes: 0 additions & 2 deletions packages/react-relay/relay-hooks/HooksImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// flowlint ambiguous-object-type:error

import typeof useFragment from './useFragment';
import type {UseLazyLoadQueryHookType} from './useLazyLoadQuery';
import type {UsePaginationFragmentType} from './usePaginationFragment';
import type {UsePreloadedQueryHookType} from './usePreloadedQuery';
import type {UseRefetchableFragmentType} from './useRefetchableFragment';
Expand All @@ -23,7 +22,6 @@ const warning = require('warning');

type HooksImplementation = {|
useFragment: useFragment,
useLazyLoadQuery: UseLazyLoadQueryHookType,
usePreloadedQuery: UsePreloadedQueryHookType,
usePaginationFragment: UsePaginationFragmentType,
useRefetchableFragment: UseRefetchableFragmentType,
Expand Down
22 changes: 1 addition & 21 deletions packages/react-relay/relay-hooks/useLazyLoadQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import type {
Variables,
} from 'relay-runtime';

const HooksImplementation = require('./HooksImplementation');
const {useTrackLoadQueryInRender} = require('./loadQuery');
const useLazyLoadQueryNode = require('./useLazyLoadQueryNode');
const useMemoOperationDescriptor = require('./useMemoOperationDescriptor');
Expand All @@ -44,7 +43,7 @@ export type UseLazyLoadQueryHookType = <TVariables: Variables, TData>(
|},
) => TData;

function useLazyLoadQuery_LEGACY<TVariables: Variables, TData>(
function useLazyLoadQuery<TVariables: Variables, TData>(
gqlQuery: Query<TVariables, TData>,
variables: TVariables,
options?: {|
Expand Down Expand Up @@ -78,23 +77,4 @@ function useLazyLoadQuery_LEGACY<TVariables: Variables, TData>(
return data;
}

function useLazyLoadQuery<TVariables: Variables, TData>(
gqlQuery: Query<TVariables, TData>,
variables: TVariables,
options?: {|
fetchKey?: string | number,
fetchPolicy?: FetchPolicy,
networkCacheConfig?: CacheConfig,
UNSTABLE_renderPolicy?: RenderPolicy,
|},
): TData {
const impl = HooksImplementation.get();
if (impl) {
return impl.useLazyLoadQuery(gqlQuery, variables, options);
} else {
// eslint-disable-next-line react-hooks/rules-of-hooks
return useLazyLoadQuery_LEGACY(gqlQuery, variables, options);
}
}

module.exports = (useLazyLoadQuery: UseLazyLoadQueryHookType);

0 comments on commit 201438e

Please sign in to comment.