mirror of
https://github.com/facebook/react.git
synced 2026-02-25 13:13:03 +00:00
Added an explicit type to all $FlowFixMe suppressions to reduce over-suppressions of new errors that might be caused on the same lines. Also removes suppressions that aren't used (e.g. in a `@noflow` file as they're purely misleading) Test Plan: yarn flow-ci
30 lines
917 B
JavaScript
30 lines
917 B
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
import type {ReactServerContext} from 'shared/ReactTypes';
|
|
|
|
import {REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED} from 'shared/ReactSymbols';
|
|
import ReactSharedInternals from 'shared/ReactSharedInternals';
|
|
import {createServerContext} from 'react';
|
|
|
|
const ContextRegistry = ReactSharedInternals.ContextRegistry;
|
|
|
|
export function getOrCreateServerContext(
|
|
globalName: string,
|
|
): ReactServerContext<any> {
|
|
if (!ContextRegistry[globalName]) {
|
|
ContextRegistry[globalName] = createServerContext(
|
|
globalName,
|
|
// $FlowFixMe[incompatible-call] function signature doesn't reflect the symbol value
|
|
REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED,
|
|
);
|
|
}
|
|
return ContextRegistry[globalName];
|
|
}
|