/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
v18.3.0
packages/react/src/ReactStartTransition.js
52 строки
2 KB
Luna Ruan
[DevTools][Transition Tracing] onTransitionComplete and onTransitionStart implmentation (#23313)
25 фев 2022, 01:28
Не верифицирован
25 фев 2022, 01:28
42f15b3
Код
Авторство
О чём код?
/** * Copyright (c) Facebook, Inc. and its 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 {StartTransitionOptions} from 'shared/ReactTypes'; import ReactCurrentBatchConfig from './ReactCurrentBatchConfig'; import {enableTransitionTracing} from 'shared/ReactFeatureFlags'; export function startTransition( scope: () => void, options?: StartTransitionOptions, ) { const prevTransition = ReactCurrentBatchConfig.transition; ReactCurrentBatchConfig.transition = {}; const currentTransition = ReactCurrentBatchConfig.transition; if (__DEV__) { ReactCurrentBatchConfig.transition._updatedFibers = new Set(); } if (enableTransitionTracing) { if (options !== undefined && options.name !== undefined) { ReactCurrentBatchConfig.transition.name = options.name; ReactCurrentBatchConfig.transition.startTime = -1; } } try { scope(); } finally { ReactCurrentBatchConfig.transition = prevTransition; if (__DEV__) { if (prevTransition === null && currentTransition._updatedFibers) { const updatedFibersCount = currentTransition._updatedFibers.size; if (updatedFibersCount > 10) { console.warn( 'Detected a large number of updates inside startTransition. ' + 'If this is due to a subscription please re-write it to use React provided hooks. ' + 'Otherwise concurrent mode guarantees are off the table.', ); } currentTransition._updatedFibers.clear(); } } } }