react-relay 11.0.2 → 13.0.0-rc.2
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.
- package/README.md +47 -0
- package/ReactRelayContainerUtils.js.flow +1 -1
- package/ReactRelayContext.js +1 -1
- package/ReactRelayContext.js.flow +3 -4
- package/ReactRelayFragmentContainer.js.flow +25 -25
- package/ReactRelayFragmentMockRenderer.js.flow +2 -2
- package/ReactRelayLocalQueryRenderer.js.flow +7 -8
- package/ReactRelayPaginationContainer.js.flow +112 -59
- package/ReactRelayQueryFetcher.js.flow +10 -11
- package/ReactRelayQueryRenderer.js.flow +116 -82
- package/ReactRelayQueryRendererContext.js.flow +1 -1
- package/ReactRelayRefetchContainer.js.flow +42 -39
- package/ReactRelayTestMocker.js.flow +17 -15
- package/ReactRelayTypes.js.flow +11 -11
- package/RelayContext.js.flow +4 -4
- package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +2 -3
- package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +12 -8
- package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +11 -7
- package/__flowtests__/RelayModern-flowtest.js.flow +79 -47
- package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +6 -5
- package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +6 -5
- package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +5 -4
- package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +5 -4
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +72 -0
- package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +72 -0
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +227 -0
- package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +164 -0
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +227 -0
- package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +164 -0
- package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +66 -0
- package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +66 -0
- package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +59 -0
- package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +61 -0
- package/assertFragmentMap.js.flow +3 -3
- package/buildReactRelayContainer.js.flow +12 -11
- package/getRootVariablesForFragments.js.flow +3 -5
- package/hooks.js +1 -1
- package/hooks.js.flow +6 -7
- package/index.js +1 -1
- package/index.js.flow +7 -8
- package/isRelayEnvironment.js.flow +1 -1
- package/jest-react/enqueueTask.js.flow +56 -0
- package/jest-react/index.js.flow +12 -0
- package/jest-react/internalAct.js.flow +138 -0
- package/legacy.js +1 -1
- package/legacy.js.flow +1 -1
- package/lib/ReactRelayContainerUtils.js +1 -1
- package/lib/ReactRelayContext.js +1 -1
- package/lib/ReactRelayFragmentContainer.js +22 -16
- package/lib/ReactRelayFragmentMockRenderer.js +3 -3
- package/lib/ReactRelayLocalQueryRenderer.js +8 -9
- package/lib/ReactRelayPaginationContainer.js +97 -39
- package/lib/ReactRelayQueryFetcher.js +3 -3
- package/lib/ReactRelayQueryRenderer.js +87 -54
- package/lib/ReactRelayQueryRendererContext.js +1 -1
- package/lib/ReactRelayRefetchContainer.js +39 -26
- package/lib/ReactRelayTestMocker.js +8 -9
- package/lib/ReactRelayTypes.js +1 -1
- package/lib/RelayContext.js +4 -3
- package/lib/assertFragmentMap.js +3 -2
- package/lib/buildReactRelayContainer.js +8 -8
- package/lib/getRootVariablesForFragments.js +2 -3
- package/lib/hooks.js +6 -6
- package/lib/index.js +8 -8
- package/lib/isRelayEnvironment.js +1 -1
- package/lib/jest-react/enqueueTask.js +53 -0
- package/lib/jest-react/index.js +13 -0
- package/lib/jest-react/internalAct.js +115 -0
- package/lib/legacy.js +1 -1
- package/lib/multi-actor/ActorChange.js +30 -0
- package/lib/multi-actor/index.js +11 -0
- package/lib/multi-actor/useRelayActorEnvironment.js +29 -0
- package/lib/readContext.js +1 -1
- package/lib/relay-hooks/EntryPointContainer.react.js +4 -4
- package/lib/relay-hooks/EntryPointTypes.flow.js +1 -1
- package/lib/relay-hooks/FragmentResource.js +342 -89
- package/lib/relay-hooks/InternalLogger.js +1 -1
- package/lib/relay-hooks/LRUCache.js +1 -1
- package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +5 -5
- package/lib/relay-hooks/MatchContainer.js +2 -2
- package/lib/relay-hooks/ProfilerContext.js +1 -1
- package/lib/relay-hooks/QueryResource.js +172 -29
- package/lib/relay-hooks/RelayEnvironmentProvider.js +6 -4
- package/lib/relay-hooks/SuspenseResource.js +130 -0
- package/lib/relay-hooks/loadEntryPoint.js +1 -1
- package/lib/relay-hooks/loadQuery.js +42 -20
- package/lib/relay-hooks/preloadQuery_DEPRECATED.js +25 -16
- package/lib/relay-hooks/prepareEntryPoint_DEPRECATED.js +1 -1
- package/lib/relay-hooks/useBlockingPaginationFragment.js +5 -6
- package/lib/relay-hooks/useEntryPointLoader.js +3 -3
- package/lib/relay-hooks/useFetchTrackingRef.js +3 -2
- package/lib/relay-hooks/useFragment.js +7 -7
- package/lib/relay-hooks/useFragmentNode.js +5 -5
- package/lib/relay-hooks/useIsMountedRef.js +1 -1
- package/lib/relay-hooks/useIsOperationNodeActive.js +3 -3
- package/lib/relay-hooks/useIsParentQueryActive.js +1 -1
- package/lib/relay-hooks/useLazyLoadQuery.js +4 -4
- package/lib/relay-hooks/useLazyLoadQueryNode.js +11 -5
- package/lib/relay-hooks/useLoadMoreFunction.js +9 -13
- package/lib/relay-hooks/useMemoOperationDescriptor.js +3 -3
- package/lib/relay-hooks/useMemoVariables.js +3 -3
- package/lib/relay-hooks/useMutation.js +18 -7
- package/lib/relay-hooks/usePaginationFragment.js +3 -4
- package/lib/relay-hooks/usePreloadedQuery.js +6 -6
- package/lib/relay-hooks/useQueryLoader.js +31 -11
- package/lib/relay-hooks/useRefetchableFragment.js +1 -1
- package/lib/relay-hooks/useRefetchableFragmentNode.js +14 -18
- package/lib/relay-hooks/useRelayEnvironment.js +3 -3
- package/lib/relay-hooks/useStaticFragmentNodeWarning.js +3 -3
- package/lib/relay-hooks/useSubscribeToInvalidationState.js +3 -2
- package/lib/relay-hooks/useSubscription.js +11 -8
- package/multi-actor/ActorChange.js.flow +58 -0
- package/multi-actor/index.js.flow +14 -0
- package/multi-actor/useRelayActorEnvironment.js.flow +49 -0
- package/package.json +3 -3
- 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/readContext.js.flow +1 -1
- package/relay-hooks/EntryPointContainer.react.js.flow +9 -16
- package/relay-hooks/EntryPointTypes.flow.js.flow +25 -26
- package/relay-hooks/FragmentResource.js.flow +359 -93
- package/relay-hooks/InternalLogger.js.flow +1 -1
- package/relay-hooks/LRUCache.js.flow +1 -1
- package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +33 -47
- package/relay-hooks/MatchContainer.js.flow +4 -3
- package/relay-hooks/ProfilerContext.js.flow +1 -1
- package/relay-hooks/QueryResource.js.flow +217 -26
- package/relay-hooks/RelayEnvironmentProvider.js.flow +15 -5
- package/relay-hooks/SuspenseResource.js.flow +115 -0
- package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +5 -4
- package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +2 -2
- package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_user.graphql.js.flow +59 -0
- package/relay-hooks/__flowtests__/__generated__/useFragmentFlowtest_users.graphql.js.flow +61 -0
- package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +11 -10
- package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +55 -32
- package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +11 -10
- package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +11 -10
- package/relay-hooks/__flowtests__/utils.js.flow +21 -32
- package/relay-hooks/loadEntryPoint.js.flow +7 -13
- package/relay-hooks/loadQuery.js.flow +50 -32
- package/relay-hooks/preloadQuery_DEPRECATED.js.flow +31 -22
- package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +7 -13
- package/relay-hooks/useBlockingPaginationFragment.js.flow +14 -12
- package/relay-hooks/useEntryPointLoader.js.flow +8 -11
- package/relay-hooks/useFetchTrackingRef.js.flow +3 -3
- package/relay-hooks/useFragment.js.flow +31 -62
- package/relay-hooks/useFragmentNode.js.flow +6 -8
- package/relay-hooks/useIsMountedRef.js.flow +1 -1
- package/relay-hooks/useIsOperationNodeActive.js.flow +4 -6
- package/relay-hooks/useIsParentQueryActive.js.flow +4 -5
- package/relay-hooks/useLazyLoadQuery.js.flow +14 -16
- package/relay-hooks/useLazyLoadQueryNode.js.flow +20 -14
- package/relay-hooks/useLoadMoreFunction.js.flow +21 -30
- package/relay-hooks/useMemoOperationDescriptor.js.flow +6 -8
- package/relay-hooks/useMemoVariables.js.flow +7 -7
- package/relay-hooks/useMutation.js.flow +27 -27
- package/relay-hooks/usePaginationFragment.js.flow +39 -45
- package/relay-hooks/usePreloadedQuery.js.flow +14 -20
- package/relay-hooks/useQueryLoader.js.flow +42 -23
- package/relay-hooks/useRefetchableFragment.js.flow +8 -9
- package/relay-hooks/useRefetchableFragmentNode.js.flow +25 -33
- package/relay-hooks/useRelayEnvironment.js.flow +3 -5
- package/relay-hooks/useStaticFragmentNodeWarning.js.flow +3 -4
- package/relay-hooks/useSubscribeToInvalidationState.js.flow +4 -7
- package/relay-hooks/useSubscription.js.flow +21 -11
- package/lib/relay-hooks/getPaginationMetadata.js +0 -41
- package/lib/relay-hooks/getPaginationVariables.js +0 -67
- package/lib/relay-hooks/getRefetchMetadata.js +0 -36
- package/lib/relay-hooks/getValueAtPath.js +0 -51
- package/relay-hooks/getPaginationMetadata.js.flow +0 -74
- package/relay-hooks/getPaginationVariables.js.flow +0 -110
- package/relay-hooks/getRefetchMetadata.js.flow +0 -80
- package/relay-hooks/getValueAtPath.js.flow +0 -46
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
* @emails oncall+relay
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
// This file is sync'd from https://github.com/facebook/react/tree/main/packages/jest-react
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var didWarnAboutMessageChannel = false;
|
|
14
|
+
var enqueueTaskImpl = null;
|
|
15
|
+
|
|
16
|
+
function enqueueTask(task) {
|
|
17
|
+
if (enqueueTaskImpl === null) {
|
|
18
|
+
try {
|
|
19
|
+
// read require off the module object to get around the bundlers.
|
|
20
|
+
// we don't want them to detect a require and bundle a Node polyfill.
|
|
21
|
+
var requireString = ('require' + Math.random()).slice(0, 7);
|
|
22
|
+
var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's
|
|
23
|
+
// version of setImmediate, bypassing fake timers if any.
|
|
24
|
+
|
|
25
|
+
enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;
|
|
26
|
+
} catch (_unused) {
|
|
27
|
+
// we're in a browser
|
|
28
|
+
// we can't use regular timers because they may still be faked
|
|
29
|
+
// so we try MessageChannel+postMessage instead
|
|
30
|
+
enqueueTaskImpl = function enqueueTaskImpl(callback) {
|
|
31
|
+
if (process.env.NODE_ENV !== "production") {
|
|
32
|
+
if (didWarnAboutMessageChannel === false) {
|
|
33
|
+
didWarnAboutMessageChannel = true;
|
|
34
|
+
|
|
35
|
+
if (typeof MessageChannel === 'undefined') {
|
|
36
|
+
console.error('This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/*global MessageChannel*/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
var channel = new MessageChannel();
|
|
44
|
+
channel.port1.onmessage = callback;
|
|
45
|
+
channel.port2.postMessage(undefined);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return enqueueTaskImpl(task);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = enqueueTask;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "act", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _internalAct.act;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _internalAct = require("./internalAct");
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
* @emails oncall+relay
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* global jest */
|
|
12
|
+
// This file is sync'd from https://github.com/facebook/react/tree/main/packages/jest-react
|
|
13
|
+
// This version of `act` is only used by our tests. Unlike the public version
|
|
14
|
+
// of `act`, it's designed to work identically in both production and
|
|
15
|
+
// development. It may have slightly different behavior from the public
|
|
16
|
+
// version, too, since our constraints in our test suite are not the same as
|
|
17
|
+
// those of developers using React — we're testing React itself, as opposed to
|
|
18
|
+
// building an app with React.
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
var enqueueTask = require('./enqueueTask');
|
|
22
|
+
|
|
23
|
+
var Scheduler = require('scheduler/unstable_mock'); // The subset of a Promise that React APIs rely on. This resolves a value.
|
|
24
|
+
// This doesn't require a return value neither from the handler nor the
|
|
25
|
+
// then function.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
var actingUpdatesScopeDepth = 0;
|
|
29
|
+
|
|
30
|
+
function act(scope) {
|
|
31
|
+
if (Scheduler.unstable_flushAllWithoutAsserting === undefined) {
|
|
32
|
+
throw Error('This version of `act` requires a special mock build of Scheduler.');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (setTimeout._isMockFunction !== true) {
|
|
36
|
+
throw Error("This version of `act` requires Jest's timer mocks " + '(i.e. jest.useFakeTimers).');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var previousActingUpdatesScopeDepth = actingUpdatesScopeDepth;
|
|
40
|
+
actingUpdatesScopeDepth++;
|
|
41
|
+
|
|
42
|
+
var unwind = function unwind() {
|
|
43
|
+
actingUpdatesScopeDepth--;
|
|
44
|
+
|
|
45
|
+
if (process.env.NODE_ENV !== "production") {
|
|
46
|
+
if (actingUpdatesScopeDepth > previousActingUpdatesScopeDepth) {
|
|
47
|
+
// if it's _less than_ previousActingUpdatesScopeDepth, then we can
|
|
48
|
+
// assume the 'other' one has warned
|
|
49
|
+
console.error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}; // TODO: This would be way simpler if 1) we required a promise to be
|
|
53
|
+
// returned and 2) we could use async/await. Since it's only our used in
|
|
54
|
+
// our test suite, we should be able to.
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
var thenable = scope();
|
|
59
|
+
|
|
60
|
+
if (typeof thenable === 'object' && thenable !== null && typeof thenable.then === 'function') {
|
|
61
|
+
return {
|
|
62
|
+
then: function then(resolve, reject) {
|
|
63
|
+
thenable.then(function () {
|
|
64
|
+
flushActWork(function () {
|
|
65
|
+
unwind();
|
|
66
|
+
resolve();
|
|
67
|
+
}, function (error) {
|
|
68
|
+
unwind();
|
|
69
|
+
reject(error);
|
|
70
|
+
});
|
|
71
|
+
}, function (error) {
|
|
72
|
+
unwind();
|
|
73
|
+
reject(error);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
} else {
|
|
78
|
+
try {
|
|
79
|
+
// TODO: Let's not support non-async scopes at all in our tests. Need to
|
|
80
|
+
// migrate existing tests.
|
|
81
|
+
var didFlushWork;
|
|
82
|
+
|
|
83
|
+
do {
|
|
84
|
+
didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
|
|
85
|
+
} while (didFlushWork);
|
|
86
|
+
} finally {
|
|
87
|
+
unwind();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
unwind();
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function flushActWork(resolve, reject) {
|
|
97
|
+
// Flush suspended fallbacks
|
|
98
|
+
// $FlowFixMe: Flow doesn't know about global Jest object
|
|
99
|
+
jest.runOnlyPendingTimers();
|
|
100
|
+
enqueueTask(function () {
|
|
101
|
+
try {
|
|
102
|
+
var didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
|
|
103
|
+
|
|
104
|
+
if (didFlushWork) {
|
|
105
|
+
flushActWork(resolve, reject);
|
|
106
|
+
} else {
|
|
107
|
+
resolve();
|
|
108
|
+
}
|
|
109
|
+
} catch (error) {
|
|
110
|
+
reject(error);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
exports.act = act;
|
package/lib/legacy.js
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
* @emails oncall+relay
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var RelayEnvironmentProvider = require('../relay-hooks/RelayEnvironmentProvider');
|
|
14
|
+
|
|
15
|
+
var useRelayActorEnvironment = require('./useRelayActorEnvironment');
|
|
16
|
+
|
|
17
|
+
var React = require('react');
|
|
18
|
+
|
|
19
|
+
function ActorChange(props) {
|
|
20
|
+
var actorEnvironment = useRelayActorEnvironment(props.actorChangePoint.__viewer);
|
|
21
|
+
var getEnvironmentForActor = React.useCallback(function (actorIdentifier) {
|
|
22
|
+
return actorEnvironment.multiActorEnvironment.forActor(actorIdentifier);
|
|
23
|
+
}, [actorEnvironment]);
|
|
24
|
+
return /*#__PURE__*/React.createElement(RelayEnvironmentProvider, {
|
|
25
|
+
environment: actorEnvironment,
|
|
26
|
+
getEnvironmentForActor: getEnvironmentForActor
|
|
27
|
+
}, props.children(props.actorChangePoint.__fragmentRef, props.actorChangePoint.__viewer));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = ActorChange;
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
* @emails oncall+relay
|
|
8
|
+
*
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
// flowlint ambiguous-object-type:error
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var invariant = require('invariant');
|
|
15
|
+
|
|
16
|
+
var _require = require('react'),
|
|
17
|
+
useContext = _require.useContext;
|
|
18
|
+
|
|
19
|
+
var ReactRelayContext = require('react-relay/ReactRelayContext');
|
|
20
|
+
|
|
21
|
+
function useRelayActorEnvironment(actorIdentifier) {
|
|
22
|
+
var context = useContext(ReactRelayContext);
|
|
23
|
+
!(context != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'useRelayActorEnvironment: Expected to have found a Relay environment provided by ' + 'a `RelayEnvironmentProvider` component. ' + 'This usually means that useRelayActorEnvironment was used in a ' + 'component that is not a descendant of a `RelayEnvironmentProvider`. ' + 'Please make sure a `RelayEnvironmentProvider` has been rendered somewhere ' + 'as a parent or ancestor of your component.') : invariant(false) : void 0;
|
|
24
|
+
var getEnvironmentForActor = context.getEnvironmentForActor;
|
|
25
|
+
!(getEnvironmentForActor != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'useRelayActorEnvironment: Expected to have a function `getEnvironmentForActor`.' + 'This usually means that `RelayEnvironmentProvider`. was not properly set up for use in the ' + 'multi actor application. Please make sure the provider has defined a `getEnvironmentForActor`.') : invariant(false) : void 0;
|
|
26
|
+
return getEnvironmentForActor(actorIdentifier);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = useRelayActorEnvironment;
|
package/lib/readContext.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
|
|
14
14
|
var ProfilerContext = require('./ProfilerContext');
|
|
15
15
|
|
|
16
|
-
var React = require('react');
|
|
17
|
-
|
|
18
16
|
var useRelayEnvironment = require('./useRelayEnvironment');
|
|
19
17
|
|
|
20
|
-
var
|
|
18
|
+
var React = require('react');
|
|
21
19
|
|
|
22
20
|
var _require = require('react'),
|
|
23
21
|
useContext = _require.useContext,
|
|
24
22
|
useEffect = _require.useEffect;
|
|
25
23
|
|
|
24
|
+
var warning = require("fbjs/lib/warning");
|
|
25
|
+
|
|
26
26
|
function EntryPointContainer(_ref) {
|
|
27
27
|
var entryPointReference = _ref.entryPointReference,
|
|
28
28
|
props = _ref.props;
|