From 201438ecfd8ce4d8eb62a0ecb1a603ef6f252bfc Mon Sep 17 00:00:00 2001 From: Dave McCabe Date: Fri, 17 Jun 2022 17:19:05 -0700 Subject: [PATCH] Deinjectify useLazyLoadQuery Reviewed By: josephsavona Differential Revision: D37252240 fbshipit-source-id: 20b64ffb3322bd35c8911e0ae40ce672fa8ee784 --- .../relay-hooks/HooksImplementation.js | 2 -- .../relay-hooks/useLazyLoadQuery.js | 22 +------------------ 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/packages/react-relay/relay-hooks/HooksImplementation.js b/packages/react-relay/relay-hooks/HooksImplementation.js index 6a63a50b30e1d..8e083f77cc61f 100644 --- a/packages/react-relay/relay-hooks/HooksImplementation.js +++ b/packages/react-relay/relay-hooks/HooksImplementation.js @@ -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'; @@ -23,7 +22,6 @@ const warning = require('warning'); type HooksImplementation = {| useFragment: useFragment, - useLazyLoadQuery: UseLazyLoadQueryHookType, usePreloadedQuery: UsePreloadedQueryHookType, usePaginationFragment: UsePaginationFragmentType, useRefetchableFragment: UseRefetchableFragmentType, diff --git a/packages/react-relay/relay-hooks/useLazyLoadQuery.js b/packages/react-relay/relay-hooks/useLazyLoadQuery.js index 498581f99308e..12c17d86fee16 100644 --- a/packages/react-relay/relay-hooks/useLazyLoadQuery.js +++ b/packages/react-relay/relay-hooks/useLazyLoadQuery.js @@ -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'); @@ -44,7 +43,7 @@ export type UseLazyLoadQueryHookType = ( |}, ) => TData; -function useLazyLoadQuery_LEGACY( +function useLazyLoadQuery( gqlQuery: Query, variables: TVariables, options?: {| @@ -78,23 +77,4 @@ function useLazyLoadQuery_LEGACY( return data; } -function useLazyLoadQuery( - gqlQuery: Query, - 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);