UNPKG

1.13 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 warning = require("fbjs/lib/warning");
14
15var _require = require('react'),
16 useRef = _require.useRef;
17
18function useStaticFragmentNodeWarning(fragmentNode, warningContext) {
19 if (process.env.NODE_ENV !== "production") {
20 // This is calling `useRef` conditionally, but based on the environment
21 // __DEV__ setting which shouldn't change. This allows us to only pay the
22 // cost of `useRef` in development mode to produce the warning.
23 // eslint-disable-next-line react-hooks/rules-of-hooks
24 var initialPropRef = useRef(fragmentNode.name);
25 process.env.NODE_ENV !== "production" ? warning(initialPropRef.current === fragmentNode.name, 'Relay: The %s has to remain the same over the lifetime of a component. ' + 'Changing it is not supported and will result in unexpected behavior.', warningContext) : void 0;
26 }
27}
28
29module.exports = useStaticFragmentNodeWarning;
\No newline at end of file