UNPKG

1.12 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// flowlint ambiguous-object-type:error
12'use strict';
13
14var ReactRelayContext = require('react-relay/ReactRelayContext');
15
16var invariant = require("fbjs/lib/invariant");
17
18var _require = require('react'),
19 useContext = _require.useContext;
20
21function useRelayEnvironment() {
22 var context = useContext(ReactRelayContext);
23 !(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 or ancestor of your component.') : invariant(false) : void 0;
24 return context.environment;
25}
26
27module.exports = useRelayEnvironment;
\No newline at end of file