react-relay 18.2.0 → 19.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/ReactRelayContainerUtils.js.flow +2 -2
  2. package/ReactRelayContext.js +1 -1
  3. package/ReactRelayFragmentContainer.js.flow +5 -7
  4. package/ReactRelayLoggingContext.js.flow +21 -0
  5. package/ReactRelayPaginationContainer.js.flow +8 -8
  6. package/ReactRelayRefetchContainer.js.flow +8 -8
  7. package/ReactRelayTypes.js.flow +18 -11
  8. package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +1 -8
  9. package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +2 -5
  10. package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +2 -5
  11. package/buildReactRelayContainer.js.flow +3 -3
  12. package/hooks.js +1 -1
  13. package/index.js +1 -1
  14. package/index.js.flow +3 -3
  15. package/legacy.js +1 -1
  16. package/lib/ReactRelayLoggingContext.js +6 -0
  17. package/lib/index.js +2 -2
  18. package/lib/relay-hooks/legacy/FragmentResource.js +3 -3
  19. package/lib/relay-hooks/legacy/useRefetchableFragmentNode.js +1 -1
  20. package/lib/relay-hooks/loadEntryPoint.js +3 -0
  21. package/lib/relay-hooks/loadQuery.js +5 -3
  22. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +7 -2
  23. package/lib/relay-hooks/readFragmentInternal.js +2 -2
  24. package/lib/relay-hooks/useFragmentInternal_CURRENT.js +11 -6
  25. package/lib/relay-hooks/useFragmentInternal_EXPERIMENTAL.js +11 -6
  26. package/lib/relay-hooks/useLoadMoreFunction.js +3 -2
  27. package/lib/relay-hooks/useLoadMoreFunction_EXPERIMENTAL.js +3 -2
  28. package/lib/relay-hooks/usePaginationFragment.js +5 -1
  29. package/lib/relay-hooks/usePrefetchableForwardPaginationFragment.js +228 -0
  30. package/lib/relay-hooks/usePrefetchableForwardPaginationFragment_EXPERIMENTAL.js +8 -8
  31. package/lib/relay-hooks/useRefetchableFragmentInternal.js +3 -3
  32. package/lib/relay-hooks/useRelayLoggingContext.js +9 -0
  33. package/package.json +3 -3
  34. package/relay-hooks/EntryPointContainer.react.js.flow +13 -17
  35. package/relay-hooks/EntryPointTypes.flow.js.flow +6 -4
  36. package/relay-hooks/MatchContainer.js.flow +1 -1
  37. package/relay-hooks/legacy/FragmentResource.js.flow +3 -6
  38. package/relay-hooks/legacy/useBlockingPaginationFragment.js.flow +2 -17
  39. package/relay-hooks/legacy/useRefetchableFragmentNode.js.flow +1 -1
  40. package/relay-hooks/loadEntryPoint.js.flow +6 -0
  41. package/relay-hooks/loadQuery.js.flow +18 -2
  42. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +18 -3
  43. package/relay-hooks/readFragmentInternal.js.flow +2 -5
  44. package/relay-hooks/useEntryPointLoader.js.flow +4 -2
  45. package/relay-hooks/useFragment.js.flow +1 -0
  46. package/relay-hooks/useFragmentInternal.js.flow +2 -0
  47. package/relay-hooks/useFragmentInternal_CURRENT.js.flow +22 -5
  48. package/relay-hooks/useFragmentInternal_EXPERIMENTAL.js.flow +24 -5
  49. package/relay-hooks/useLazyLoadQuery.js.flow +4 -4
  50. package/relay-hooks/useLoadMoreFunction.js.flow +7 -7
  51. package/relay-hooks/useLoadMoreFunction_EXPERIMENTAL.js.flow +5 -7
  52. package/relay-hooks/usePaginationFragment.js.flow +6 -10
  53. package/relay-hooks/usePrefetchableForwardPaginationFragment.js.flow +436 -0
  54. package/relay-hooks/usePrefetchableForwardPaginationFragment_EXPERIMENTAL.js.flow +15 -13
  55. package/relay-hooks/usePreloadedQuery.js.flow +1 -0
  56. package/relay-hooks/useQueryLoader.js.flow +5 -1
  57. package/relay-hooks/useQueryLoader_EXPERIMENTAL.js.flow +3 -1
  58. package/relay-hooks/useRefetchableFragment.js.flow +1 -0
  59. package/relay-hooks/useRefetchableFragmentInternal.js.flow +3 -3
  60. package/relay-hooks/useRelayLoggingContext.js.flow +21 -0
  61. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +1 -0
  62. package/react-relay-hooks.js +0 -4
  63. package/react-relay-hooks.min.js +0 -9
  64. package/react-relay-legacy.js +0 -4
  65. package/react-relay-legacy.min.js +0 -9
  66. package/react-relay.js +0 -4
  67. package/react-relay.min.js +0 -9
@@ -48,7 +48,9 @@ type UseEntryPointLoaderHookReturnType<
48
48
  type NullEntryPointReference = {
49
49
  kind: 'NullEntryPointReference',
50
50
  };
51
- const initialNullEntryPointReferenceState = {kind: 'NullEntryPointReference'};
51
+ const initialNullEntryPointReferenceState: NullEntryPointReference = {
52
+ kind: 'NullEntryPointReference',
53
+ };
52
54
 
53
55
  hook useLoadEntryPoint<
54
56
  TEntryPointParams: {...},
@@ -122,7 +124,7 @@ hook useLoadEntryPoint<
122
124
 
123
125
  const disposeEntryPoint = useCallback(() => {
124
126
  if (isMountedRef.current) {
125
- const nullEntryPointReference = {
127
+ const nullEntryPointReference: NullEntryPointReference = {
126
128
  kind: 'NullEntryPointReference',
127
129
  };
128
130
  undisposedEntryPointReferencesRef.current.add(nullEntryPointReference);
@@ -54,6 +54,7 @@ hook useFragment(fragment: GraphQLTaggedNode, key: mixed): mixed {
54
54
  if (__DEV__) {
55
55
  // eslint-disable-next-line react-hooks/rules-of-hooks
56
56
  // $FlowFixMe[react-rule-hook]
57
+ // $FlowFixMe[react-rule-hook-conditional]
57
58
  useDebugValue({fragment: fragmentNode.name, data});
58
59
  }
59
60
  return data;
@@ -26,6 +26,7 @@ hook useFragmentInternal(
26
26
  ): ?SelectorData | Array<?SelectorData> {
27
27
  if (RelayFeatureFlags.ENABLE_ACTIVITY_COMPATIBILITY) {
28
28
  // $FlowFixMe[react-rule-hook] - the condition is static
29
+ // $FlowFixMe[react-rule-hook-conditional]
29
30
  return useFragmentInternal_EXPERIMENTAL(
30
31
  fragmentNode,
31
32
  fragmentRef,
@@ -34,6 +35,7 @@ hook useFragmentInternal(
34
35
  );
35
36
  }
36
37
  // $FlowFixMe[react-rule-hook] - the condition is static
38
+ // $FlowFixMe[react-rule-hook-conditional]
37
39
  return useFragmentInternal_CURRENT(
38
40
  fragmentNode,
39
41
  fragmentRef,
@@ -26,6 +26,7 @@ import type {MissingClientEdgeRequestInfo} from 'relay-runtime/store/RelayStoreT
26
26
 
27
27
  const {getQueryResourceForEnvironment} = require('./QueryResource');
28
28
  const useRelayEnvironment = require('./useRelayEnvironment');
29
+ const useRelayLoggingContext = require('./useRelayLoggingContext');
29
30
  const invariant = require('invariant');
30
31
  const {useDebugValue, useEffect, useMemo, useRef, useState} = require('react');
31
32
  const {
@@ -109,15 +110,21 @@ function getSuspendingLiveResolver(
109
110
  function handlePotentialSnapshotErrorsForState(
110
111
  environment: IEnvironment,
111
112
  state: FragmentState,
113
+ loggingContext: mixed | void,
112
114
  ): void {
113
115
  if (state.kind === 'singular') {
114
116
  handlePotentialSnapshotErrors(
115
117
  environment,
116
- state.snapshot.errorResponseFields,
118
+ state.snapshot.fieldErrors,
119
+ loggingContext,
117
120
  );
118
121
  } else if (state.kind === 'plural') {
119
122
  for (const snapshot of state.snapshots) {
120
- handlePotentialSnapshotErrors(environment, snapshot.errorResponseFields);
123
+ handlePotentialSnapshotErrors(
124
+ environment,
125
+ snapshot.fieldErrors,
126
+ loggingContext,
127
+ );
121
128
  }
122
129
  }
123
130
  }
@@ -153,7 +160,7 @@ function handleMissedUpdates(
153
160
  missingLiveResolverFields: currentSnapshot.missingLiveResolverFields,
154
161
  seenRecords: currentSnapshot.seenRecords,
155
162
  selector: currentSnapshot.selector,
156
- errorResponseFields: currentSnapshot.errorResponseFields,
163
+ fieldErrors: currentSnapshot.fieldErrors,
157
164
  };
158
165
  return [
159
166
  updatedData !== state.snapshot.data,
@@ -177,7 +184,7 @@ function handleMissedUpdates(
177
184
  missingLiveResolverFields: currentSnapshot.missingLiveResolverFields,
178
185
  seenRecords: currentSnapshot.seenRecords,
179
186
  selector: currentSnapshot.selector,
180
- errorResponseFields: currentSnapshot.errorResponseFields,
187
+ fieldErrors: currentSnapshot.fieldErrors,
181
188
  };
182
189
  if (updatedData !== snapshot.data) {
183
190
  didMissUpdates = true;
@@ -403,6 +410,12 @@ hook useFragmentInternal(
403
410
  );
404
411
 
405
412
  const environment = useRelayEnvironment();
413
+ let loggerContext;
414
+ if (RelayFeatureFlags.ENABLE_UI_CONTEXT_ON_RELAY_LOGGER) {
415
+ // $FlowFixMe[react-rule-hook] - the condition is static
416
+ // $FlowFixMe[react-rule-hook-conditional]
417
+ loggerContext = useRelayLoggingContext();
418
+ }
406
419
  const [_state, setState] = useState<FragmentState>(() =>
407
420
  getFragmentState(environment, fragmentSelector),
408
421
  );
@@ -454,6 +467,7 @@ hook useFragmentInternal(
454
467
  // always or never run for a given invocation of this hook.
455
468
  // eslint-disable-next-line react-hooks/rules-of-hooks
456
469
  // $FlowFixMe[react-rule-hook]
470
+ // $FlowFixMe[react-rule-hook-conditional]
457
471
  const [clientEdgeQueries, activeRequestPromises] = useMemo(() => {
458
472
  const missingClientEdges = getMissingClientEdges(state);
459
473
  // eslint-disable-next-line no-shadow
@@ -485,6 +499,7 @@ hook useFragmentInternal(
485
499
  // See above note
486
500
  // eslint-disable-next-line react-hooks/rules-of-hooks
487
501
  // $FlowFixMe[react-rule-hook]
502
+ // $FlowFixMe[react-rule-hook-conditional]
488
503
  useEffect(() => {
489
504
  const QueryResource = getQueryResourceForEnvironment(environment);
490
505
  if (clientEdgeQueries?.length) {
@@ -541,7 +556,7 @@ hook useFragmentInternal(
541
556
 
542
557
  // Report required fields only if we're not suspending, since that means
543
558
  // they're missing even though we are out of options for possibly fetching them:
544
- handlePotentialSnapshotErrorsForState(environment, state);
559
+ handlePotentialSnapshotErrorsForState(environment, state, loggerContext);
545
560
 
546
561
  const hasPendingStateChanges = useRef<boolean>(false);
547
562
 
@@ -594,6 +609,7 @@ hook useFragmentInternal(
594
609
  const fragmentRefIsNullish = fragmentRef == null; // for less sensitive memoization
595
610
  // eslint-disable-next-line react-hooks/rules-of-hooks
596
611
  // $FlowFixMe[react-rule-hook]
612
+ // $FlowFixMe[react-rule-hook-conditional]
597
613
  data = useMemo(() => {
598
614
  if (state.kind === 'bailout') {
599
615
  // Bailout state can happen if the fragmentRef is a plural array that is empty or has no
@@ -645,6 +661,7 @@ hook useFragmentInternal(
645
661
  if (__DEV__) {
646
662
  // eslint-disable-next-line react-hooks/rules-of-hooks
647
663
  // $FlowFixMe[react-rule-hook]
664
+ // $FlowFixMe[react-rule-hook-conditional]
648
665
  useDebugValue({fragment: fragmentNode.name, data});
649
666
  }
650
667
 
@@ -26,6 +26,7 @@ import type {MissingClientEdgeRequestInfo} from 'relay-runtime/store/RelayStoreT
26
26
 
27
27
  const {getQueryResourceForEnvironment} = require('./QueryResource');
28
28
  const useRelayEnvironment = require('./useRelayEnvironment');
29
+ const useRelayLoggingContext = require('./useRelayLoggingContext');
29
30
  const invariant = require('invariant');
30
31
  const {useDebugValue, useEffect, useMemo, useRef, useState} = require('react');
31
32
  const {
@@ -121,15 +122,21 @@ function getSuspendingLiveResolver(
121
122
  function handlePotentialSnapshotErrorsForState(
122
123
  environment: IEnvironment,
123
124
  state: FragmentState,
125
+ loggingContext: mixed | void,
124
126
  ): void {
125
127
  if (state.kind === 'singular') {
126
128
  handlePotentialSnapshotErrors(
127
129
  environment,
128
- state.snapshot.errorResponseFields,
130
+ state.snapshot.fieldErrors,
131
+ loggingContext,
129
132
  );
130
133
  } else if (state.kind === 'plural') {
131
134
  for (const snapshot of state.snapshots) {
132
- handlePotentialSnapshotErrors(environment, snapshot.errorResponseFields);
135
+ handlePotentialSnapshotErrors(
136
+ environment,
137
+ snapshot.fieldErrors,
138
+ loggingContext,
139
+ );
133
140
  }
134
141
  }
135
142
  }
@@ -165,7 +172,7 @@ function handleMissedUpdates(
165
172
  missingLiveResolverFields: currentSnapshot.missingLiveResolverFields,
166
173
  seenRecords: currentSnapshot.seenRecords,
167
174
  selector: currentSnapshot.selector,
168
- errorResponseFields: currentSnapshot.errorResponseFields,
175
+ fieldErrors: currentSnapshot.fieldErrors,
169
176
  };
170
177
  return [
171
178
  updatedData !== state.snapshot.data,
@@ -191,7 +198,7 @@ function handleMissedUpdates(
191
198
  missingLiveResolverFields: currentSnapshot.missingLiveResolverFields,
192
199
  seenRecords: currentSnapshot.seenRecords,
193
200
  selector: currentSnapshot.selector,
194
- errorResponseFields: currentSnapshot.errorResponseFields,
201
+ fieldErrors: currentSnapshot.fieldErrors,
195
202
  };
196
203
  if (updatedData !== snapshot.data) {
197
204
  didMissUpdates = true;
@@ -431,6 +438,12 @@ hook useFragmentInternal_EXPERIMENTAL(
431
438
  );
432
439
 
433
440
  const environment = useRelayEnvironment();
441
+ let loggerContext;
442
+ if (RelayFeatureFlags.ENABLE_UI_CONTEXT_ON_RELAY_LOGGER) {
443
+ // $FlowFixMe[react-rule-hook] - the condition is static
444
+ // $FlowFixMe[react-rule-hook-conditional]
445
+ loggerContext = useRelayLoggingContext();
446
+ }
434
447
  const [_state, setState] = useState<FragmentState>(() =>
435
448
  getFragmentState(environment, fragmentSelector),
436
449
  );
@@ -469,6 +482,7 @@ hook useFragmentInternal_EXPERIMENTAL(
469
482
  // always or never run for a given invocation of this hook.
470
483
  // eslint-disable-next-line react-hooks/rules-of-hooks
471
484
  // $FlowFixMe[react-rule-hook]
485
+ // $FlowFixMe[react-rule-hook-conditional]
472
486
  const [clientEdgeQueries, activeRequestPromises] = useMemo(() => {
473
487
  const missingClientEdges = getMissingClientEdges(state);
474
488
  // eslint-disable-next-line no-shadow
@@ -500,6 +514,7 @@ hook useFragmentInternal_EXPERIMENTAL(
500
514
  // See above note
501
515
  // eslint-disable-next-line react-hooks/rules-of-hooks
502
516
  // $FlowFixMe[react-rule-hook]
517
+ // $FlowFixMe[react-rule-hook-conditional]
503
518
  useEffect(() => {
504
519
  const QueryResource = getQueryResourceForEnvironment(environment);
505
520
  if (clientEdgeQueries?.length) {
@@ -556,7 +571,7 @@ hook useFragmentInternal_EXPERIMENTAL(
556
571
 
557
572
  // Report required fields only if we're not suspending, since that means
558
573
  // they're missing even though we are out of options for possibly fetching them:
559
- handlePotentialSnapshotErrorsForState(environment, state);
574
+ handlePotentialSnapshotErrorsForState(environment, state, loggerContext);
560
575
 
561
576
  // We emulate CRUD effects using a ref and two effects:
562
577
  // - The ref tracks the current state (including updates from the subscription)
@@ -577,6 +592,7 @@ hook useFragmentInternal_EXPERIMENTAL(
577
592
  selector: ?ReaderSelector,
578
593
  environment: IEnvironment,
579
594
  } | null>(null);
595
+ // $FlowFixMe[react-rule-hook] - the condition is static
580
596
  useEffect(() => {
581
597
  const storeSubscription = storeSubscriptionRef.current;
582
598
  if (storeSubscription != null) {
@@ -629,6 +645,7 @@ hook useFragmentInternal_EXPERIMENTAL(
629
645
  environment: state.environment,
630
646
  };
631
647
  }, [state]);
648
+ // $FlowFixMe[react-rule-hook] - the condition is static
632
649
  useEffect(() => {
633
650
  if (storeSubscriptionRef.current == null && state.kind !== 'bailout') {
634
651
  const dispose = subscribeToSnapshot(state.environment, state, setState);
@@ -656,6 +673,7 @@ hook useFragmentInternal_EXPERIMENTAL(
656
673
  const fragmentRefIsNullish = fragmentRef == null; // for less sensitive memoization
657
674
  // eslint-disable-next-line react-hooks/rules-of-hooks
658
675
  // $FlowFixMe[react-rule-hook]
676
+ // $FlowFixMe[react-rule-hook-conditional]
659
677
  data = useMemo(() => {
660
678
  if (state.kind === 'bailout') {
661
679
  // Bailout state can happen if the fragmentRef is a plural array that is empty or has no
@@ -707,6 +725,7 @@ hook useFragmentInternal_EXPERIMENTAL(
707
725
  if (__DEV__) {
708
726
  // eslint-disable-next-line react-hooks/rules-of-hooks
709
727
  // $FlowFixMe[react-rule-hook]
728
+ // $FlowFixMe[react-rule-hook-conditional]
710
729
  useDebugValue({fragment: fragmentNode.name, data});
711
730
  }
712
731
 
@@ -32,23 +32,23 @@ const {
32
32
  export type UseLazyLoadQueryHookType = hook <TVariables: Variables, TData>(
33
33
  gqlQuery: Query<TVariables, TData>,
34
34
  variables: TVariables,
35
- options?: {
35
+ options?: $ReadOnly<{
36
36
  fetchKey?: string | number,
37
37
  fetchPolicy?: FetchPolicy,
38
38
  networkCacheConfig?: CacheConfig,
39
39
  UNSTABLE_renderPolicy?: RenderPolicy,
40
- },
40
+ }>,
41
41
  ) => TData;
42
42
 
43
43
  hook useLazyLoadQuery<TVariables: Variables, TData>(
44
44
  gqlQuery: Query<TVariables, TData>,
45
45
  variables: TVariables,
46
- options?: {
46
+ options?: $ReadOnly<{
47
47
  fetchKey?: string | number,
48
48
  fetchPolicy?: FetchPolicy,
49
49
  networkCacheConfig?: CacheConfig,
50
50
  UNSTABLE_renderPolicy?: RenderPolicy,
51
- },
51
+ }>,
52
52
  ): TData {
53
53
  const environment = useRelayEnvironment();
54
54
 
@@ -67,9 +67,11 @@ hook useLoadMoreFunction<TVariables: Variables>(
67
67
  ): [LoadMoreFn<TVariables>, boolean, () => void] {
68
68
  if (RelayFeatureFlags.ENABLE_ACTIVITY_COMPATIBILITY) {
69
69
  // $FlowFixMe[react-rule-hook] - the condition is static
70
+ // $FlowFixMe[react-rule-hook-conditional]
70
71
  return useLoadMoreFunction_EXPERIMENTAL(args);
71
72
  }
72
73
  // $FlowFixMe[react-rule-hook] - the condition is static
74
+ // $FlowFixMe[react-rule-hook-conditional]
73
75
  return useLoadMoreFunction_CURRENT(args);
74
76
  }
75
77
 
@@ -138,6 +140,8 @@ hook useLoadMoreFunction_CURRENT<TVariables: Variables>(
138
140
  };
139
141
  }, [disposeFetch]);
140
142
 
143
+ const isRequestInvalid = fragmentData == null || isParentQueryActive;
144
+
141
145
  const loadMore = useCallback(
142
146
  (
143
147
  count: number,
@@ -166,11 +170,8 @@ hook useLoadMoreFunction_CURRENT<TVariables: Variables>(
166
170
  }
167
171
 
168
172
  const fragmentSelector = getSelector(fragmentNode, fragmentRef);
169
- if (
170
- isFetchingRef.current === true ||
171
- fragmentData == null ||
172
- isParentQueryActive
173
- ) {
173
+
174
+ if (isFetchingRef.current === true || isRequestInvalid) {
174
175
  if (fragmentSelector == null) {
175
176
  warning(
176
177
  false,
@@ -271,8 +272,7 @@ hook useLoadMoreFunction_CURRENT<TVariables: Variables>(
271
272
  disposeFetch,
272
273
  completeFetch,
273
274
  isFetchingRef,
274
- isParentQueryActive,
275
- fragmentData,
275
+ isRequestInvalid,
276
276
  fragmentNode.name,
277
277
  fragmentRef,
278
278
  componentDisplayName,
@@ -135,6 +135,8 @@ hook useLoadMoreFunction_EXPERIMENTAL<TVariables: Variables>(
135
135
  connectionPathInFragmentData,
136
136
  );
137
137
 
138
+ const isRequestInvalid = fragmentData == null || isParentQueryActive;
139
+
138
140
  const isMountedRef = useIsMountedRef();
139
141
  const loadMore = useCallback(
140
142
  (
@@ -164,11 +166,8 @@ hook useLoadMoreFunction_EXPERIMENTAL<TVariables: Variables>(
164
166
  }
165
167
 
166
168
  const fragmentSelector = getSelector(fragmentNode, fragmentRef);
167
- if (
168
- fetchStatusRef.current.kind === 'fetching' ||
169
- fragmentData == null ||
170
- isParentQueryActive
171
- ) {
169
+
170
+ if (fetchStatusRef.current.kind === 'fetching' || isRequestInvalid) {
172
171
  if (fragmentSelector == null) {
173
172
  warning(
174
173
  false,
@@ -267,8 +266,7 @@ hook useLoadMoreFunction_EXPERIMENTAL<TVariables: Variables>(
267
266
  identifierValue,
268
267
  direction,
269
268
  cursor,
270
- isParentQueryActive,
271
- fragmentData,
269
+ isRequestInvalid,
272
270
  fragmentNode.name,
273
271
  fragmentRef,
274
272
  componentDisplayName,
@@ -16,8 +16,6 @@ import type {Options} from './useRefetchableFragmentInternal';
16
16
  import type {
17
17
  Disposable,
18
18
  FragmentType,
19
- GraphQLResponse,
20
- Observer,
21
19
  RefetchableFragment,
22
20
  Variables,
23
21
  } from 'relay-runtime';
@@ -28,6 +26,7 @@ const useRelayEnvironment = require('./useRelayEnvironment');
28
26
  const useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
29
27
  const {useCallback, useDebugValue, useState} = require('react');
30
28
  const {
29
+ RelayFeatureFlags,
31
30
  getFragment,
32
31
  getFragmentIdentifier,
33
32
  getPaginationMetadata,
@@ -145,6 +144,7 @@ hook usePaginationFragment<
145
144
  if (__DEV__) {
146
145
  // eslint-disable-next-line react-hooks/rules-of-hooks
147
146
  // $FlowFixMe[react-rule-hook]
147
+ // $FlowFixMe[react-rule-hook-conditional]
148
148
  useDebugValue({
149
149
  fragment: fragmentNode.name,
150
150
  data: fragmentData,
@@ -168,14 +168,7 @@ hook usePaginationFragment<
168
168
  }
169
169
 
170
170
  hook useLoadMore<TVariables: Variables>(
171
- args: $Diff<
172
- UseLoadMoreFunctionArgs,
173
- {
174
- observer: Observer<GraphQLResponse>,
175
- onReset: () => void,
176
- ...
177
- },
178
- >,
171
+ args: Omit<UseLoadMoreFunctionArgs, 'observer' | 'onReset'>,
179
172
  ): [LoadMoreFn<TVariables>, boolean, boolean, () => void] {
180
173
  const environment = useRelayEnvironment();
181
174
  const [isLoadingMore, reallySetIsLoadingMore] = useState(false);
@@ -196,6 +189,9 @@ hook useLoadMore<TVariables: Variables>(
196
189
  start: () => setIsLoadingMore(true),
197
190
  complete: () => setIsLoadingMore(false),
198
191
  error: () => setIsLoadingMore(false),
192
+ unsubscribe: RelayFeatureFlags.ENABLE_USE_PAGINATION_IS_LOADING_FIX
193
+ ? () => setIsLoadingMore(false)
194
+ : undefined,
199
195
  };
200
196
  const handleReset = () => setIsLoadingMore(false);
201
197
  const [loadMore, hasMore, disposeFetch] = useLoadMoreFunction<TVariables>({