UNPKG

1.08 kBJavaScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its 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'use strict';
12
13var ReactRelayContext = require('react-relay/ReactRelayContext');
14
15var invariant = require("fbjs/lib/invariant");
16
17var _require = require('react'),
18 useContext = _require.useContext;
19
20function useRelayEnvironment() {
21 var context = useContext(ReactRelayContext);
22 !(context != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'useRelayEnvironment: Expected to have found a Relay environment provided by ' + 'a `RelayEnvironmentProvider` component. ' + 'This usually means that useRelayEnvironment 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 of ancestor your compontent.') : invariant(false) : void 0;
23 return context.environment;
24}
25
26module.exports = useRelayEnvironment;
\No newline at end of file