/
ashipov
/
react
Обзор
Документация
Войти
/
ashipov
/
react
Код
Запросы
0
Задачи 2.0
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
packages/react-server/src/flight/ReactFlightCurrentOwner.js
30 строк
755 B
Sebastian Markbåge
[Flight] Track Owner on AsyncLocalStorage When Available (#28807)
03 май 2024, 23:29
Не верифицирован
03 май 2024, 23:29
d5c3034
Код
Авторство
О чём код?
/** * 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 {ReactComponentInfo} from 'shared/ReactTypes'; import { supportsComponentStorage, componentStorage, } from '../ReactFlightServerConfig'; let currentOwner: ReactComponentInfo | null = null; export function setCurrentOwner(componentInfo: null | ReactComponentInfo) { currentOwner = componentInfo; } export function resolveOwner(): null | ReactComponentInfo { if (currentOwner) return currentOwner; if (supportsComponentStorage) { const owner = componentStorage.getStore(); if (owner) return owner; } return null; }