react-relay 15.0.0 → 16.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/ReactRelayContext.js +1 -1
- package/ReactRelayQueryFetcher.js.flow +1 -5
- package/ReactRelayQueryRenderer.js.flow +9 -36
- package/ReactRelayTypes.js.flow +1 -0
- package/buildReactRelayContainer.js.flow +3 -1
- package/hooks.js +1 -1
- package/index.js +1 -1
- package/legacy.js +1 -1
- package/lib/ReactRelayContainerUtils.js +0 -11
- package/lib/ReactRelayContext.js +0 -11
- package/lib/ReactRelayFragmentContainer.js +6 -78
- package/lib/ReactRelayFragmentMockRenderer.js +0 -11
- package/lib/ReactRelayLocalQueryRenderer.js +0 -17
- package/lib/ReactRelayPaginationContainer.js +5 -208
- package/lib/ReactRelayQueryFetcher.js +2 -51
- package/lib/ReactRelayQueryRenderer.js +6 -94
- package/lib/ReactRelayQueryRendererContext.js +0 -11
- package/lib/ReactRelayRefetchContainer.js +5 -91
- package/lib/ReactRelayTestMocker.js +9 -85
- package/lib/ReactRelayTypes.js +0 -11
- package/lib/RelayContext.js +0 -21
- package/lib/assertFragmentMap.js +0 -15
- package/lib/buildReactRelayContainer.js +0 -19
- package/lib/getRootVariablesForFragments.js +0 -14
- package/lib/hooks.js +0 -15
- package/lib/index.js +0 -17
- package/lib/isRelayEnvironment.js +1 -18
- package/lib/jest-react/enqueueTask.js +0 -20
- package/lib/jest-react/internalAct.js +0 -38
- package/lib/legacy.js +0 -15
- package/lib/multi-actor/ActorChange.js +0 -11
- package/lib/multi-actor/index.js +0 -11
- package/lib/multi-actor/useRelayActorEnvironment.js +0 -11
- package/lib/relay-hooks/EntryPointContainer.react.js +0 -11
- package/lib/relay-hooks/EntryPointTypes.flow.js +1 -14
- package/lib/relay-hooks/FragmentResource.js +76 -132
- package/lib/relay-hooks/HooksImplementation.js +1 -12
- package/lib/relay-hooks/InternalLogger.js +0 -11
- package/lib/relay-hooks/LRUCache.js +0 -22
- package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +0 -18
- package/lib/relay-hooks/MatchContainer.js +0 -94
- package/lib/relay-hooks/NestedRelayEntryPointBuilderUtils.js +9 -0
- package/lib/relay-hooks/ProfilerContext.js +0 -15
- package/lib/relay-hooks/QueryResource.js +2 -68
- package/lib/relay-hooks/RelayEnvironmentProvider.js +0 -11
- package/lib/relay-hooks/SuspenseResource.js +0 -34
- package/lib/relay-hooks/{react-cache/readFragmentInternal_REACT_CACHE.js → experimental/readFragmentInternal_EXPERIMENTAL.js} +5 -29
- package/lib/relay-hooks/{react-cache/useFragmentInternal_REACT_CACHE.js → experimental/useFragmentInternal_EXPERIMENTAL.js} +35 -100
- package/lib/relay-hooks/{react-cache/useFragment_REACT_CACHE.js → experimental/useFragment_EXPERIMENTAL.js} +1 -16
- package/lib/relay-hooks/{react-cache/usePaginationFragment_REACT_CACHE.js → experimental/usePaginationFragment_EXPERIMENTAL.js} +2 -24
- package/lib/relay-hooks/{react-cache/useRefetchableFragmentInternal_REACT_CACHE.js → experimental/useRefetchableFragmentInternal_EXPERIMENTAL.js} +14 -98
- package/lib/relay-hooks/{react-cache/useRefetchableFragment_REACT_CACHE.js → experimental/useRefetchableFragment_EXPERIMENTAL.js} +1 -15
- package/lib/relay-hooks/loadEntryPoint.js +1 -24
- package/lib/relay-hooks/loadQuery.js +2 -106
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +2 -27
- package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +0 -13
- package/lib/relay-hooks/useBlockingPaginationFragment.js +0 -42
- package/lib/relay-hooks/useClientQuery.js +0 -18
- package/lib/relay-hooks/useEntryPointLoader.js +0 -69
- package/lib/relay-hooks/useFetchTrackingRef.js +0 -26
- package/lib/relay-hooks/useFragment.js +0 -17
- package/lib/relay-hooks/useFragmentNode.js +2 -32
- package/lib/relay-hooks/useIsMountedRef.js +0 -11
- package/lib/relay-hooks/useIsOperationNodeActive.js +0 -11
- package/lib/relay-hooks/useIsParentQueryActive.js +0 -11
- package/lib/relay-hooks/useLazyLoadQuery.js +0 -18
- package/lib/relay-hooks/useLazyLoadQueryNode.js +12 -37
- package/lib/relay-hooks/useLoadMoreFunction.js +9 -34
- package/lib/relay-hooks/useMemoOperationDescriptor.js +0 -11
- package/lib/relay-hooks/useMemoVariables.js +0 -17
- package/lib/relay-hooks/useMutation.js +0 -11
- package/lib/relay-hooks/usePaginationFragment.js +1 -26
- package/lib/relay-hooks/usePreloadedQuery.js +0 -27
- package/lib/relay-hooks/useQueryLoader.js +0 -74
- package/lib/relay-hooks/useRefetchableFragment.js +0 -16
- package/lib/relay-hooks/useRefetchableFragmentNode.js +14 -97
- package/lib/relay-hooks/useRelayEnvironment.js +0 -11
- package/lib/relay-hooks/useStaticFragmentNodeWarning.js +0 -15
- package/lib/relay-hooks/useSubscribeToInvalidationState.js +0 -25
- package/lib/relay-hooks/useSubscription.js +0 -15
- package/lib/relay-hooks/useUnsafeRef_DEPRECATED.js +0 -17
- package/package.json +2 -2
- package/react-relay-hooks.js +2 -2
- package/react-relay-hooks.min.js +2 -2
- package/react-relay-legacy.js +2 -2
- package/react-relay-legacy.min.js +2 -2
- package/react-relay.js +2 -2
- package/react-relay.min.js +2 -2
- package/relay-hooks/EntryPointContainer.react.js.flow +5 -0
- package/relay-hooks/EntryPointTypes.flow.js.flow +34 -35
- package/relay-hooks/FragmentResource.js.flow +114 -26
- package/relay-hooks/HooksImplementation.js.flow +3 -1
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +4 -2
- package/relay-hooks/NestedRelayEntryPointBuilderUtils.js.flow +51 -0
- package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +7 -5
- package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +5 -0
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +5 -0
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +2 -0
- package/relay-hooks/{react-cache/readFragmentInternal_REACT_CACHE.js.flow → experimental/readFragmentInternal_EXPERIMENTAL.js.flow} +4 -3
- package/relay-hooks/{react-cache/useFragmentInternal_REACT_CACHE.js.flow → experimental/useFragmentInternal_EXPERIMENTAL.js.flow} +32 -14
- package/relay-hooks/{react-cache/useFragment_REACT_CACHE.js.flow → experimental/useFragment_EXPERIMENTAL.js.flow} +4 -10
- package/relay-hooks/{react-cache/usePaginationFragment_REACT_CACHE.js.flow → experimental/usePaginationFragment_EXPERIMENTAL.js.flow} +30 -59
- package/relay-hooks/{react-cache/useRefetchableFragmentInternal_REACT_CACHE.js.flow → experimental/useRefetchableFragmentInternal_EXPERIMENTAL.js.flow} +30 -23
- package/relay-hooks/experimental/useRefetchableFragment_EXPERIMENTAL.js.flow +49 -0
- package/relay-hooks/loadEntryPoint.js.flow +4 -2
- package/relay-hooks/loadQuery.js.flow +21 -1
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +4 -2
- package/relay-hooks/useBlockingPaginationFragment.js.flow +10 -17
- package/relay-hooks/useClientQuery.js.flow +2 -2
- package/relay-hooks/useFragmentNode.js.flow +2 -2
- package/relay-hooks/useLazyLoadQueryNode.js.flow +17 -1
- package/relay-hooks/useLoadMoreFunction.js.flow +15 -9
- package/relay-hooks/useMutation.js.flow +26 -9
- package/relay-hooks/usePaginationFragment.js.flow +7 -15
- package/relay-hooks/useQueryLoader.js.flow +2 -8
- package/relay-hooks/useRefetchableFragment.js.flow +14 -16
- package/relay-hooks/useRefetchableFragmentNode.js.flow +33 -20
- package/lib/relay-hooks/react-cache/RelayReactCache.js +0 -32
- package/lib/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js +0 -290
- package/lib/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js +0 -49
- package/lib/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js +0 -110
- package/relay-hooks/react-cache/RelayReactCache.js.flow +0 -40
- package/relay-hooks/react-cache/getQueryResultOrFetchQuery_REACT_CACHE.js.flow +0 -430
- package/relay-hooks/react-cache/useLazyLoadQuery_REACT_CACHE.js.flow +0 -70
- package/relay-hooks/react-cache/usePreloadedQuery_REACT_CACHE.js.flow +0 -150
- package/relay-hooks/react-cache/useRefetchableFragment_REACT_CACHE.js.flow +0 -65
@@ -1,18 +1,7 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
* @oncall relay
|
10
|
-
*/
|
11
|
-
|
12
1
|
'use strict';
|
13
2
|
|
14
3
|
var useStaticFragmentNodeWarning = require('../useStaticFragmentNodeWarning');
|
15
|
-
var useRefetchableFragmentInternal = require('./
|
4
|
+
var useRefetchableFragmentInternal = require('./useRefetchableFragmentInternal_EXPERIMENTAL');
|
16
5
|
var _require = require('react'),
|
17
6
|
useDebugValue = _require.useDebugValue;
|
18
7
|
var _require2 = require('relay-runtime'),
|
@@ -24,14 +13,11 @@ function useRefetchableFragment(fragmentInput, fragmentRef) {
|
|
24
13
|
fragmentData = _useRefetchableFragme.fragmentData,
|
25
14
|
refetch = _useRefetchableFragme.refetch;
|
26
15
|
if (process.env.NODE_ENV !== "production") {
|
27
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
28
16
|
useDebugValue({
|
29
17
|
fragment: fragmentNode.name,
|
30
18
|
data: fragmentData
|
31
19
|
});
|
32
20
|
}
|
33
|
-
/* $FlowExpectedError[prop-missing] : Exposed options is a subset of internal
|
34
|
-
* options */
|
35
21
|
return [fragmentData, refetch];
|
36
22
|
}
|
37
23
|
module.exports = useRefetchableFragment;
|
@@ -1,20 +1,8 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
* @oncall relay
|
10
|
-
*/
|
11
|
-
|
12
1
|
'use strict';
|
13
2
|
|
14
3
|
var _require = require('./loadQuery'),
|
15
4
|
loadQuery = _require.loadQuery;
|
16
5
|
function loadEntryPoint(environmentProvider, entryPoint, entryPointParams) {
|
17
|
-
// Start loading the code for the entrypoint
|
18
6
|
var loadingPromise = null;
|
19
7
|
if (entryPoint.root.getModuleIfRequired() == null) {
|
20
8
|
loadingPromise = entryPoint.root.load();
|
@@ -34,8 +22,6 @@ function loadEntryPoint(environmentProvider, entryPoint, entryPointParams) {
|
|
34
22
|
parameters = _queries$queryPropNam.parameters,
|
35
23
|
variables = _queries$queryPropNam.variables;
|
36
24
|
var environment = environmentProvider.getEnvironment(environmentProviderOptions);
|
37
|
-
|
38
|
-
// $FlowFixMe[underconstrained-implicit-instantiation]
|
39
25
|
preloadedQueries[queryPropName] = loadQuery(environment, parameters, variables, {
|
40
26
|
fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
|
41
27
|
networkCacheConfig: options === null || options === void 0 ? void 0 : options.networkCacheConfig,
|
@@ -84,18 +70,9 @@ function loadEntryPoint(environmentProvider, entryPoint, entryPointParams) {
|
|
84
70
|
loadingPromise = (_loadingPromise = loadingPromise) !== null && _loadingPromise !== void 0 ? _loadingPromise : entryPoint.root.load();
|
85
71
|
throw loadingPromise;
|
86
72
|
}
|
87
|
-
|
88
|
-
// On certain platforms, getting an es6 module with a default export from a JSResource will return an object like
|
89
|
-
// {default: module}, so let's assume that if the "component" has a static property named "default"
|
90
|
-
// that it's actually an es6 module wrapper, so unwrap it. This won't work for React classes with a static property named "default", but
|
91
|
-
// that's probably a worthwhile trade-off.
|
92
|
-
var component =
|
93
|
-
// $FlowIgnore[prop-missing]
|
94
|
-
componentModule["default"] != null ? componentModule["default"] : componentModule;
|
95
|
-
// $FlowFixMe[incompatible-cast] - trust me Flow, its entryPoint component
|
73
|
+
var component = componentModule["default"] != null ? componentModule["default"] : componentModule;
|
96
74
|
return component;
|
97
75
|
},
|
98
|
-
// $FlowFixMe[unsafe-getters-setters] - this has no side effects
|
99
76
|
get isDisposed() {
|
100
77
|
return isDisposed;
|
101
78
|
},
|
@@ -1,14 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
* @oncall relay
|
10
|
-
*/
|
11
|
-
|
12
1
|
'use strict';
|
13
2
|
|
14
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
@@ -30,37 +19,18 @@ var fetchKey = 100001;
|
|
30
19
|
function useTrackLoadQueryInRender() {
|
31
20
|
if (RenderDispatcher === null) {
|
32
21
|
var _React$__SECRET_INTER, _React$__SECRET_INTER2;
|
33
|
-
|
34
|
-
// ensure here that this function isn't called inside render.
|
35
|
-
RenderDispatcher = // $FlowFixMe[prop-missing]
|
36
|
-
(_React$__SECRET_INTER = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _React$__SECRET_INTER === void 0 ? void 0 : (_React$__SECRET_INTER2 = _React$__SECRET_INTER.ReactCurrentDispatcher) === null || _React$__SECRET_INTER2 === void 0 ? void 0 : _React$__SECRET_INTER2.current;
|
22
|
+
RenderDispatcher = (_React$__SECRET_INTER = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _React$__SECRET_INTER === void 0 ? void 0 : (_React$__SECRET_INTER2 = _React$__SECRET_INTER.ReactCurrentDispatcher) === null || _React$__SECRET_INTER2 === void 0 ? void 0 : _React$__SECRET_INTER2.current;
|
37
23
|
}
|
38
24
|
}
|
39
25
|
function loadQuery(environment, preloadableRequest, variables, options, environmentProviderOptions) {
|
40
26
|
var _React$__SECRET_INTER3, _React$__SECRET_INTER4, _options$__nameForWar, _options$fetchPolicy;
|
41
|
-
|
42
|
-
var CurrentDispatcher = // $FlowFixMe[prop-missing]
|
43
|
-
(_React$__SECRET_INTER3 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _React$__SECRET_INTER3 === void 0 ? void 0 : (_React$__SECRET_INTER4 = _React$__SECRET_INTER3.ReactCurrentDispatcher) === null || _React$__SECRET_INTER4 === void 0 ? void 0 : _React$__SECRET_INTER4.current;
|
27
|
+
var CurrentDispatcher = (_React$__SECRET_INTER3 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _React$__SECRET_INTER3 === void 0 ? void 0 : (_React$__SECRET_INTER4 = _React$__SECRET_INTER3.ReactCurrentDispatcher) === null || _React$__SECRET_INTER4 === void 0 ? void 0 : _React$__SECRET_INTER4.current;
|
44
28
|
process.env.NODE_ENV !== "production" ? warning(RenderDispatcher == null || CurrentDispatcher !== RenderDispatcher, 'Relay: `%s` should not be called inside a React render function.', (_options$__nameForWar = options === null || options === void 0 ? void 0 : options.__nameForWarning) !== null && _options$__nameForWar !== void 0 ? _options$__nameForWar : 'loadQuery') : void 0;
|
45
|
-
|
46
|
-
// Every time you call loadQuery, we will generate a new fetchKey.
|
47
|
-
// This will ensure that every query reference that is created and
|
48
|
-
// passed to usePreloadedQuery is independently evaluated,
|
49
|
-
// even if they are for the same query/variables.
|
50
|
-
// Specifically, we want to avoid a case where we try to refetch a
|
51
|
-
// query by calling loadQuery a second time, and have the Suspense
|
52
|
-
// cache in usePreloadedQuery reuse the cached result instead of
|
53
|
-
// re-evaluating the new query ref and triggering a refetch if
|
54
|
-
// necessary.
|
55
29
|
fetchKey++;
|
56
30
|
var fetchPolicy = (_options$fetchPolicy = options === null || options === void 0 ? void 0 : options.fetchPolicy) !== null && _options$fetchPolicy !== void 0 ? _options$fetchPolicy : 'store-or-network';
|
57
31
|
var networkCacheConfig = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, options === null || options === void 0 ? void 0 : options.networkCacheConfig), {}, {
|
58
32
|
force: true
|
59
33
|
});
|
60
|
-
|
61
|
-
// executeWithNetworkSource will retain and execute an operation
|
62
|
-
// against the Relay store, given an Observable that would provide
|
63
|
-
// the network events for the operation.
|
64
34
|
var retainReference;
|
65
35
|
var didExecuteNetworkSource = false;
|
66
36
|
var executeWithNetworkSource = function executeWithNetworkSource(operation, networkObservable) {
|
@@ -70,53 +40,18 @@ function loadQuery(environment, preloadableRequest, variables, options, environm
|
|
70
40
|
source: networkObservable
|
71
41
|
});
|
72
42
|
};
|
73
|
-
|
74
|
-
// N.B. For loadQuery, we unconventionally want to return an Observable
|
75
|
-
// that isn't lazily executed, meaning that we don't want to wait
|
76
|
-
// until the returned Observable is subscribed to to actually start
|
77
|
-
// fetching and executing an operation; i.e. we want to execute the
|
78
|
-
// operation eagerly, when loadQuery is called.
|
79
|
-
// For this reason, we use an intermediate executionSubject which
|
80
|
-
// allows us to capture the events that occur during the eager execution
|
81
|
-
// of the operation, and then replay them to the Observable we
|
82
|
-
// ultimately return.
|
83
43
|
var executionSubject = new ReplaySubject();
|
84
44
|
var returnedObservable = Observable.create(function (sink) {
|
85
45
|
return executionSubject.subscribe(sink);
|
86
46
|
});
|
87
47
|
var unsubscribeFromNetworkRequest;
|
88
48
|
var networkError = null;
|
89
|
-
// makeNetworkRequest will immediately start a raw network request if
|
90
|
-
// one isn't already in flight and return an Observable that when
|
91
|
-
// subscribed to will replay the network events that have occured so far,
|
92
|
-
// as well as subsequent events.
|
93
49
|
var didMakeNetworkRequest = false;
|
94
50
|
var makeNetworkRequest = function makeNetworkRequest(params) {
|
95
|
-
// N.B. this function is called synchronously or not at all
|
96
|
-
// didMakeNetworkRequest is safe to rely on in the returned value
|
97
|
-
// Even if the request gets deduped below, we still wan't to return an
|
98
|
-
// observable that provides the replayed network events for the query,
|
99
|
-
// so we set this to true before deduping, to guarantee that the
|
100
|
-
// `source` observable is returned.
|
101
51
|
didMakeNetworkRequest = true;
|
102
52
|
var observable;
|
103
53
|
var subject = new ReplaySubject();
|
104
54
|
if (RelayFeatureFlags.ENABLE_LOAD_QUERY_REQUEST_DEDUPING === true) {
|
105
|
-
// Here, we are calling fetchQueryDeduped at the network layer level,
|
106
|
-
// which ensures that only a single network request is active for a given
|
107
|
-
// (environment, identifier) pair.
|
108
|
-
// Since network requests can be started /before/ we have the query ast
|
109
|
-
// necessary to process the results, we need to dedupe the raw requests
|
110
|
-
// separately from deduping the operation execution; specifically,
|
111
|
-
// if `loadQuery` is called multiple times before the query ast is available,
|
112
|
-
// we still want the network request to be deduped.
|
113
|
-
// - If a duplicate active network request is found, it will return an
|
114
|
-
// Observable that replays the events of the already active request.
|
115
|
-
// - If no duplicate active network request is found, it will call the fetchFn
|
116
|
-
// to start the request, and return an Observable that will replay
|
117
|
-
// the events from the network request.
|
118
|
-
// We provide an extra key to the identifier to distinguish deduping
|
119
|
-
// of raw network requests vs deduping of operation executions.
|
120
55
|
var identifier = 'raw-network-request-' + getRequestIdentifier(params, variables);
|
121
56
|
observable = fetchQueryDeduped(environment, identifier, function () {
|
122
57
|
var network = environment.getNetwork();
|
@@ -151,31 +86,8 @@ function loadQuery(environment, preloadableRequest, variables, options, environm
|
|
151
86
|
var unsubscribeFromExecution;
|
152
87
|
var executeDeduped = function executeDeduped(operation, fetchFn) {
|
153
88
|
if (RelayFeatureFlags.ENABLE_LOAD_QUERY_REQUEST_DEDUPING === true) {
|
154
|
-
// N.B. at this point, if we're calling execute with a query ast (OperationDescriptor),
|
155
|
-
// we are guaranteed to have started a network request. We set this to
|
156
|
-
// true here as well since `makeNetworkRequest` might get skipped in the case
|
157
|
-
// where the query ast is already available and the query executions get deduped.
|
158
|
-
// Even if the execution gets deduped below, we still wan't to return
|
159
|
-
// an observable that provides the replayed network events for the query,
|
160
|
-
// so we set this to true before deduping, to guarantee that the `source`
|
161
|
-
// observable is returned.
|
162
89
|
didMakeNetworkRequest = true;
|
163
90
|
}
|
164
|
-
|
165
|
-
// Here, we are calling fetchQueryDeduped, which ensures that only
|
166
|
-
// a single operation is active for a given (environment, identifier) pair,
|
167
|
-
// and also tracks the active state of the operation, which is necessary
|
168
|
-
// for our Suspense infra to later be able to suspend (or not) on
|
169
|
-
// active operations. Even though we already dedupe raw network requests,
|
170
|
-
// we also need to dedupe and keep track operation execution for our Suspense
|
171
|
-
// infra, and we also want to avoid processing responses more than once, for
|
172
|
-
// the cases where `loadQuery` might be called multiple times after the query ast
|
173
|
-
// is available.
|
174
|
-
// - If a duplicate active operation is found, it will return an
|
175
|
-
// Observable that replays the events of the already active operation.
|
176
|
-
// - If no duplicate active operation is found, it will call the fetchFn
|
177
|
-
// to execute the operation, and return an Observable that will provide
|
178
|
-
// the events for executing the operation.
|
179
91
|
var _fetchQueryDeduped$su = fetchQueryDeduped(environment, operation.request.identifier, fetchFn).subscribe({
|
180
92
|
error: function error(err) {
|
181
93
|
executionSubject.error(err);
|
@@ -195,15 +107,9 @@ function loadQuery(environment, preloadableRequest, variables, options, environm
|
|
195
107
|
if (fetchPolicy === 'store-only') {
|
196
108
|
return;
|
197
109
|
}
|
198
|
-
|
199
|
-
// N.B. If the fetch policy allows fulfillment from the store but the
|
200
|
-
// environment already has the data for that operation cached in the store,
|
201
|
-
// then we do nothing.
|
202
110
|
var shouldFetch = fetchPolicy !== 'store-or-network' || environment.check(operation).status !== 'available';
|
203
111
|
if (shouldFetch) {
|
204
112
|
executeDeduped(operation, function () {
|
205
|
-
// N.B. Since we have the operation synchronously available here,
|
206
|
-
// we can immediately fetch and execute the operation.
|
207
113
|
var networkObservable = makeNetworkRequest(concreteRequest.params);
|
208
114
|
var executeObservable = executeWithNetworkSource(operation, networkObservable);
|
209
115
|
return executeObservable;
|
@@ -223,15 +129,7 @@ function loadQuery(environment, preloadableRequest, variables, options, environm
|
|
223
129
|
if (_module != null) {
|
224
130
|
checkAvailabilityAndExecute(_module);
|
225
131
|
} else {
|
226
|
-
// If the module isn't synchronously available, we launch the
|
227
|
-
// network request immediately if the fetchPolicy might produce
|
228
|
-
// a network fetch, regardless of the state of the store cache. We
|
229
|
-
// do this because we can't check if a query is cached without the
|
230
|
-
// ast, and we know that if we don't have the query ast
|
231
|
-
// available, then this query could've never been written to the
|
232
|
-
// store in the first place, so it couldn't have been cached.
|
233
132
|
var networkObservable = fetchPolicy === 'store-only' ? null : makeNetworkRequest(params);
|
234
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
235
133
|
var _PreloadableQueryRegi = PreloadableQueryRegistry.onLoad(queryId, function (preloadedModule) {
|
236
134
|
cancelOnLoadCallback();
|
237
135
|
var operation = createOperationDescriptor(preloadedModule, variables, networkCacheConfig);
|
@@ -289,11 +187,9 @@ function loadQuery(environment, preloadableRequest, variables, options, environm
|
|
289
187
|
cancelNetworkRequest: cancelNetworkRequest,
|
290
188
|
fetchKey: fetchKey,
|
291
189
|
id: queryId,
|
292
|
-
// $FlowFixMe[unsafe-getters-setters] - this has no side effects
|
293
190
|
get isDisposed() {
|
294
191
|
return isDisposed || isReleased;
|
295
192
|
},
|
296
|
-
// $FlowFixMe[unsafe-getters-setters] - this has no side effects
|
297
193
|
get networkError() {
|
298
194
|
return networkError;
|
299
195
|
},
|
@@ -1,14 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
* @oncall relay
|
10
|
-
*/
|
11
|
-
|
12
1
|
'use strict';
|
13
2
|
|
14
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
@@ -20,10 +9,7 @@ var _require = require('relay-runtime'),
|
|
20
9
|
createOperationDescriptor = _require.createOperationDescriptor,
|
21
10
|
getRequest = _require.getRequest,
|
22
11
|
getRequestIdentifier = _require.getRequestIdentifier;
|
23
|
-
|
24
|
-
// Expire results by this delay after they resolve.
|
25
|
-
var DEFAULT_PREFETCH_TIMEOUT = 30 * 1000; // 30 seconds
|
26
|
-
|
12
|
+
var DEFAULT_PREFETCH_TIMEOUT = 30 * 1000;
|
27
13
|
var WEAKMAP_SUPPORTED = typeof WeakMap === 'function';
|
28
14
|
var STORE_OR_NETWORK_DEFAULT = 'store-or-network';
|
29
15
|
var pendingQueriesByEnvironment = WEAKMAP_SUPPORTED ? new WeakMap() : new Map();
|
@@ -33,7 +19,7 @@ function preloadQuery(environment, preloadableRequest, variables, options, envir
|
|
33
19
|
_pendingQueries = new Map();
|
34
20
|
pendingQueriesByEnvironment.set(environment, _pendingQueries);
|
35
21
|
}
|
36
|
-
var pendingQueries = _pendingQueries;
|
22
|
+
var pendingQueries = _pendingQueries;
|
37
23
|
var queryEntry = preloadQueryDeduped(environment, pendingQueries, preloadableRequest, variables, options);
|
38
24
|
var source = queryEntry.kind === 'network' ? Observable.create(function (sink) {
|
39
25
|
var subscription;
|
@@ -52,8 +38,6 @@ function preloadQuery(environment, preloadableRequest, variables, options, envir
|
|
52
38
|
return;
|
53
39
|
}
|
54
40
|
setTimeout(function () {
|
55
|
-
// Clear the cache entry after the default timeout
|
56
|
-
// null-check for Flow
|
57
41
|
if (queryEntry != null) {
|
58
42
|
cleanup(pendingQueries, queryEntry);
|
59
43
|
}
|
@@ -115,15 +99,12 @@ function preloadQueryDeduped(environment, pendingQueries, preloadableRequest, va
|
|
115
99
|
};
|
116
100
|
if (!environment.isServer() && prevQueryEntry == null) {
|
117
101
|
setTimeout(function () {
|
118
|
-
// Clear the cache entry after the default timeout
|
119
|
-
// null-check for Flow
|
120
102
|
if (nextQueryEntry != null) {
|
121
103
|
cleanup(pendingQueries, nextQueryEntry);
|
122
104
|
}
|
123
105
|
}, DEFAULT_PREFETCH_TIMEOUT);
|
124
106
|
}
|
125
107
|
} else if (prevQueryEntry == null || prevQueryEntry.kind !== 'network') {
|
126
|
-
// Should fetch but we're not already fetching: fetch!
|
127
108
|
var source = network.execute(params, variables, networkCacheConfig, null);
|
128
109
|
var subject = new ReplaySubject();
|
129
110
|
nextQueryEntry = {
|
@@ -144,8 +125,6 @@ function preloadQueryDeduped(environment, pendingQueries, preloadableRequest, va
|
|
144
125
|
return;
|
145
126
|
}
|
146
127
|
setTimeout(function () {
|
147
|
-
// Clear the cache entry after the default timeout
|
148
|
-
// null-check for Flow
|
149
128
|
if (nextQueryEntry != null) {
|
150
129
|
cleanup(pendingQueries, nextQueryEntry);
|
151
130
|
}
|
@@ -169,10 +148,6 @@ function preloadQueryDeduped(environment, pendingQueries, preloadableRequest, va
|
|
169
148
|
return nextQueryEntry;
|
170
149
|
}
|
171
150
|
function cleanup(pendingQueries, entry) {
|
172
|
-
// Reload the entry by its cache key and only invalidate if its the identical
|
173
|
-
// entry instance. This ensures that if the same query/variables are fetched
|
174
|
-
// successively that a timeout/expiration from an earlier fetch doesn't clear
|
175
|
-
// a subsequent fetch.
|
176
151
|
var currentEntry = pendingQueries.get(entry.cacheKey);
|
177
152
|
if (currentEntry != null && currentEntry === entry) {
|
178
153
|
if (currentEntry.kind === 'network') {
|
@@ -1,21 +1,8 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
* @oncall relay
|
10
|
-
*/
|
11
|
-
|
12
1
|
'use strict';
|
13
2
|
|
14
3
|
var preloadQuery = require('./preloadQuery_DEPRECATED');
|
15
4
|
function prepareEntryPoint(environmentProvider, entryPoint, entryPointParams) {
|
16
|
-
// Start loading the code for the entrypoint
|
17
5
|
if (entryPoint.root.getModuleIfRequired() == null) {
|
18
|
-
// $FlowFixMe[unused-promise]
|
19
6
|
entryPoint.root.load();
|
20
7
|
}
|
21
8
|
var preloadProps = entryPoint.getPreloadProps(entryPointParams);
|
@@ -1,14 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
* @oncall relay
|
10
|
-
*/
|
11
|
-
|
12
1
|
'use strict';
|
13
2
|
|
14
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
@@ -34,7 +23,6 @@ function useBlockingPaginationFragment(fragmentInput, parentFragmentRef) {
|
|
34
23
|
useStaticFragmentNodeWarning(fragmentNode, "first argument of ".concat(componentDisplayName));
|
35
24
|
var _getPaginationMetadat = getPaginationMetadata(fragmentNode, componentDisplayName),
|
36
25
|
connectionPathInFragmentData = _getPaginationMetadat.connectionPathInFragmentData,
|
37
|
-
identifierField = _getPaginationMetadat.identifierField,
|
38
26
|
paginationRequest = _getPaginationMetadat.paginationRequest,
|
39
27
|
paginationMetadata = _getPaginationMetadat.paginationMetadata,
|
40
28
|
stream = _getPaginationMetadat.stream;
|
@@ -46,8 +34,6 @@ function useBlockingPaginationFragment(fragmentInput, parentFragmentRef) {
|
|
46
34
|
disableStoreUpdates = _useRefetchableFragme.disableStoreUpdates,
|
47
35
|
enableStoreUpdates = _useRefetchableFragme.enableStoreUpdates;
|
48
36
|
var fragmentIdentifier = getFragmentIdentifier(fragmentNode, fragmentRef);
|
49
|
-
|
50
|
-
// Backward pagination
|
51
37
|
var _useLoadMore = useLoadMore({
|
52
38
|
componentDisplayName: componentDisplayName,
|
53
39
|
connectionPathInFragmentData: connectionPathInFragmentData,
|
@@ -58,15 +44,12 @@ function useBlockingPaginationFragment(fragmentInput, parentFragmentRef) {
|
|
58
44
|
fragmentIdentifier: fragmentIdentifier,
|
59
45
|
fragmentNode: fragmentNode,
|
60
46
|
fragmentRef: fragmentRef,
|
61
|
-
identifierField: identifierField,
|
62
47
|
paginationMetadata: paginationMetadata,
|
63
48
|
paginationRequest: paginationRequest
|
64
49
|
}),
|
65
50
|
loadPrevious = _useLoadMore[0],
|
66
51
|
hasPrevious = _useLoadMore[1],
|
67
52
|
disposeFetchPrevious = _useLoadMore[2];
|
68
|
-
|
69
|
-
// Forward pagination
|
70
53
|
var _useLoadMore2 = useLoadMore({
|
71
54
|
componentDisplayName: componentDisplayName,
|
72
55
|
connectionPathInFragmentData: connectionPathInFragmentData,
|
@@ -77,7 +60,6 @@ function useBlockingPaginationFragment(fragmentInput, parentFragmentRef) {
|
|
77
60
|
fragmentIdentifier: fragmentIdentifier,
|
78
61
|
fragmentNode: fragmentNode,
|
79
62
|
fragmentRef: fragmentRef,
|
80
|
-
identifierField: identifierField,
|
81
63
|
paginationMetadata: paginationMetadata,
|
82
64
|
paginationRequest: paginationRequest
|
83
65
|
}),
|
@@ -92,7 +74,6 @@ function useBlockingPaginationFragment(fragmentInput, parentFragmentRef) {
|
|
92
74
|
}));
|
93
75
|
}, [disposeFetchNext, disposeFetchPrevious, refetch]);
|
94
76
|
return {
|
95
|
-
// $FlowFixMe[incompatible-cast]
|
96
77
|
data: fragmentData,
|
97
78
|
loadNext: loadNext,
|
98
79
|
loadPrevious: loadPrevious,
|
@@ -121,13 +102,7 @@ function useLoadMore(args) {
|
|
121
102
|
};
|
122
103
|
var observer = {
|
123
104
|
complete: promiseResolve,
|
124
|
-
// NOTE: loadMore is a no-op if a request is already in flight, so we
|
125
|
-
// can safely assume that `start` will only be called once while a
|
126
|
-
// request is in flight.
|
127
105
|
start: function start() {
|
128
|
-
// NOTE: We disable store updates when we suspend to ensure
|
129
|
-
// that higher-pri updates from the Relay store don't disrupt
|
130
|
-
// any Suspense timeouts passed via withSuspenseConfig.
|
131
106
|
disableStoreUpdates();
|
132
107
|
var promise = new Promise(function (resolve) {
|
133
108
|
promiseResolveRef.current = function () {
|
@@ -138,14 +113,7 @@ function useLoadMore(args) {
|
|
138
113
|
requestPromiseRef.current = promise;
|
139
114
|
setRequestPromise(promise);
|
140
115
|
},
|
141
|
-
// NOTE: Since streaming is disallowed with this hook, this means that the
|
142
|
-
// first payload will always contain the entire next page of items,
|
143
|
-
// while subsequent paylaods will contain @defer'd payloads.
|
144
|
-
// This allows us to unsuspend here, on the first payload, and allow
|
145
|
-
// descendant components to suspend on their respective @defer payloads
|
146
116
|
next: promiseResolve,
|
147
|
-
// TODO: Handle error; we probably don't want to throw an error
|
148
|
-
// and blow away the whole list of items.
|
149
117
|
error: promiseResolve
|
150
118
|
};
|
151
119
|
var _useLoadMoreFunction = useLoadMoreFunction((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, loadMoreArgs), {}, {
|
@@ -155,23 +123,13 @@ function useLoadMore(args) {
|
|
155
123
|
loadMore = _useLoadMoreFunction[0],
|
156
124
|
hasMore = _useLoadMoreFunction[1],
|
157
125
|
disposeFetch = _useLoadMoreFunction[2];
|
158
|
-
|
159
|
-
// NOTE: To determine if we need to suspend, we check that the promise in
|
160
|
-
// state is the same as the promise on the ref, which ensures that we
|
161
|
-
// wont incorrectly suspend on other higher-pri updates before the update
|
162
|
-
// to suspend has committed.
|
163
126
|
if (requestPromise != null && requestPromise === requestPromiseRef.current) {
|
164
127
|
throw requestPromise;
|
165
128
|
}
|
166
129
|
useEffect(function () {
|
167
130
|
if (requestPromise !== requestPromiseRef.current) {
|
168
|
-
// NOTE: After suspense pagination has resolved, we re-enable store updates
|
169
|
-
// for this fragment. This may cause the component to re-render if
|
170
|
-
// we missed any updates to the fragment data other than the pagination update.
|
171
131
|
enableStoreUpdates();
|
172
132
|
}
|
173
|
-
// NOTE: We know the identity of enableStoreUpdates wont change
|
174
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
175
133
|
}, [requestPromise]);
|
176
134
|
return [loadMore, hasMore, disposeFetch];
|
177
135
|
}
|
@@ -1,27 +1,9 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
* @oncall relay
|
10
|
-
*/
|
11
|
-
|
12
1
|
'use strict';
|
13
2
|
|
14
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
15
4
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
16
5
|
var useLazyLoadQuery = require('./useLazyLoadQuery');
|
17
|
-
|
18
|
-
/**
|
19
|
-
* This hook can be used to render client-only queries.
|
20
|
-
* These queries are consist of queries for client-only data,
|
21
|
-
* schematized via local schema extensions and/or Relay resolvers.
|
22
|
-
*/
|
23
6
|
function useClientQuery(gqlQuery, variables, options) {
|
24
|
-
// $FlowFixMe[incompatible-type] client queries can be used with useLazyLoadQuery, but only with `store-only` policy.
|
25
7
|
var query = gqlQuery;
|
26
8
|
return useLazyLoadQuery(query, variables, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, options), {}, {
|
27
9
|
fetchPolicy: 'store-only'
|
@@ -1,14 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
* @oncall relay
|
10
|
-
*/
|
11
|
-
|
12
1
|
'use strict';
|
13
2
|
|
14
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
@@ -27,26 +16,6 @@ var initialNullEntryPointReferenceState = {
|
|
27
16
|
};
|
28
17
|
function useLoadEntryPoint(environmentProvider, entryPoint, options) {
|
29
18
|
var _options$TEST_ONLY__i, _options$TEST_ONLY__i2, _options$TEST_ONLY__i3, _options$TEST_ONLY__i4;
|
30
|
-
/**
|
31
|
-
* We want to always call `entryPointReference.dispose()` for every call to
|
32
|
-
* `setEntryPointReference(loadEntryPoint(...))` so that no leaks of data in Relay
|
33
|
-
* stores will occur.
|
34
|
-
*
|
35
|
-
* However, a call to `setState(newState)` is not always followed by a commit where
|
36
|
-
* this value is reflected in the state. Thus, we cannot reliably clean up each ref
|
37
|
-
* with `useEffect(() => () => entryPointReference.dispose(), [entryPointReference])`.
|
38
|
-
*
|
39
|
-
* Instead, we keep track of each call to `loadEntryPoint` in a ref.
|
40
|
-
* Relying on the fact that if a state change commits, no state changes that were
|
41
|
-
* initiated prior to the currently committing state change will ever subsequently
|
42
|
-
* commit, we can safely dispose of all preloaded entry point references
|
43
|
-
* associated with state changes initiated prior to the currently committing state
|
44
|
-
* change.
|
45
|
-
*
|
46
|
-
* Finally, when the hook unmounts, we also dispose of all remaining uncommitted
|
47
|
-
* entry point references.
|
48
|
-
*/
|
49
|
-
|
50
19
|
useTrackLoadQueryInRender();
|
51
20
|
var initialEntryPointReferenceInternal = (_options$TEST_ONLY__i = options === null || options === void 0 ? void 0 : (_options$TEST_ONLY__i2 = options.TEST_ONLY__initialEntryPointData) === null || _options$TEST_ONLY__i2 === void 0 ? void 0 : _options$TEST_ONLY__i2.entryPointReference) !== null && _options$TEST_ONLY__i !== void 0 ? _options$TEST_ONLY__i : initialNullEntryPointReferenceState;
|
52
21
|
var initialEntryPointParamsInternal = (_options$TEST_ONLY__i3 = options === null || options === void 0 ? void 0 : (_options$TEST_ONLY__i4 = options.TEST_ONLY__initialEntryPointData) === null || _options$TEST_ONLY__i4 === void 0 ? void 0 : _options$TEST_ONLY__i4.entryPointParams) !== null && _options$TEST_ONLY__i3 !== void 0 ? _options$TEST_ONLY__i3 : null;
|
@@ -78,53 +47,17 @@ function useLoadEntryPoint(environmentProvider, entryPoint, options) {
|
|
78
47
|
var maybeHiddenOrFastRefresh = useRef(false);
|
79
48
|
useEffect(function () {
|
80
49
|
return function () {
|
81
|
-
// Attempt to detect if the component was
|
82
|
-
// hidden (by Offscreen API), or fast refresh occured;
|
83
|
-
// Only in these situations would the effect cleanup
|
84
|
-
// for "unmounting" run multiple times, so if
|
85
|
-
// we are ever able to read this ref with a value
|
86
|
-
// of true, it means that one of these cases
|
87
|
-
// has happened.
|
88
50
|
maybeHiddenOrFastRefresh.current = true;
|
89
51
|
};
|
90
52
|
}, []);
|
91
53
|
useEffect(function () {
|
92
54
|
if (maybeHiddenOrFastRefresh.current === true) {
|
93
|
-
// This block only runs if the component has previously "unmounted"
|
94
|
-
// due to it being hidden by the Offscreen API, or during fast refresh.
|
95
|
-
// At this point, the current entryPointReference will have been disposed
|
96
|
-
// by the previous cleanup, so instead of attempting to
|
97
|
-
// do our regular commit setup, which would incorrectly leave our
|
98
|
-
// current entryPointReference disposed, we need to load the entryPoint again
|
99
|
-
// and force a re-render by calling entryPointLoaderCallback again,
|
100
|
-
// so that the entryPointReference's queries are correctly re-retained, and
|
101
|
-
// potentially refetched if necessary.
|
102
55
|
maybeHiddenOrFastRefresh.current = false;
|
103
56
|
if (entryPointReference.kind !== 'NullEntryPointReference' && entryPointParams != null) {
|
104
57
|
entryPointLoaderCallback(entryPointParams);
|
105
58
|
}
|
106
59
|
return;
|
107
60
|
}
|
108
|
-
|
109
|
-
// When a new entryPointReference is committed, we iterate over all
|
110
|
-
// entrypoint refs in undisposedEntryPointReferences and dispose all of
|
111
|
-
// the refs that aren't the currently committed one. This ensures
|
112
|
-
// that we don't leave any dangling entrypoint references for the
|
113
|
-
// case that loadEntryPoint is called multiple times before commit; when
|
114
|
-
// this happens, multiple state updates will be scheduled, but only one
|
115
|
-
// will commit, meaning that we need to keep track of and dispose any
|
116
|
-
// query references that don't end up committing.
|
117
|
-
// - We are relying on the fact that sets iterate in insertion order, and we
|
118
|
-
// can remove items from a set as we iterate over it (i.e. no iterator
|
119
|
-
// invalidation issues.) Thus, it is safe to loop through
|
120
|
-
// undisposedEntryPointReferences until we find entryPointReference, and
|
121
|
-
// remove and dispose all previous references.
|
122
|
-
// - We are guaranteed to find entryPointReference in the set, because if a
|
123
|
-
// state change results in a commit, no state changes initiated prior to that
|
124
|
-
// one will be committed, and we are disposing and removing references
|
125
|
-
// associated with commits that were initiated prior to the currently
|
126
|
-
// committing state change. (A useEffect callback is called during the commit
|
127
|
-
// phase.)
|
128
61
|
var undisposedEntryPointReferences = undisposedEntryPointReferencesRef.current;
|
129
62
|
if (isMountedRef.current) {
|
130
63
|
var _iterator = (0, _createForOfIteratorHelper2["default"])(undisposedEntryPointReferences),
|
@@ -149,8 +82,6 @@ function useLoadEntryPoint(environmentProvider, entryPoint, options) {
|
|
149
82
|
}, [entryPointReference, entryPointParams, entryPointLoaderCallback, isMountedRef]);
|
150
83
|
useEffect(function () {
|
151
84
|
return function disposeAllRemainingEntryPointReferences() {
|
152
|
-
// undisposedEntryPointReferences.current is never reassigned
|
153
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
154
85
|
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(undisposedEntryPointReferencesRef.current),
|
155
86
|
_step2;
|
156
87
|
try {
|
@@ -1,33 +1,9 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @format
|
9
|
-
* @oncall relay
|
10
|
-
*/
|
11
|
-
|
12
1
|
'use strict';
|
13
2
|
|
14
3
|
var useUnsafeRef_DEPRECATED = require('./useUnsafeRef_DEPRECATED');
|
15
4
|
var _require = require('react'),
|
16
5
|
useCallback = _require.useCallback,
|
17
6
|
useEffect = _require.useEffect;
|
18
|
-
|
19
|
-
/**
|
20
|
-
* This hook returns a mutable React ref that holds the value of whether a
|
21
|
-
* fetch request is in flight. The reason this is a mutable ref instead of
|
22
|
-
* state is because we don't actually want to trigger an update when this
|
23
|
-
* changes, but instead synchronously keep track of whether the network request
|
24
|
-
* is in flight, for example in order to bail out of a request if one is
|
25
|
-
* already in flight. If this was state, due to the nature of concurrent
|
26
|
-
* updates, this value wouldn't be in sync with when the request is actually
|
27
|
-
* in flight.
|
28
|
-
* The additional functions returned by this Hook can be used to mutate
|
29
|
-
* the ref.
|
30
|
-
*/
|
31
7
|
function useFetchTrackingRef() {
|
32
8
|
var subscriptionRef = useUnsafeRef_DEPRECATED(null);
|
33
9
|
var isFetchingRef = useUnsafeRef_DEPRECATED(false);
|
@@ -46,8 +22,6 @@ function useFetchTrackingRef() {
|
|
46
22
|
subscriptionRef.current = null;
|
47
23
|
isFetchingRef.current = false;
|
48
24
|
}, []);
|
49
|
-
|
50
|
-
// Dipose of ongoing fetch on unmount
|
51
25
|
useEffect(function () {
|
52
26
|
return disposeFetch;
|
53
27
|
}, [disposeFetch]);
|