mirror of
https://github.com/zebrajr/react.git
synced 2025-12-07 12:20:38 +01:00
When React schedules a rendering task, it passes a `timeout` option based on its expiration time. This is intended to avoid starvation by other React updates. However, it also affects the relative priority of React tasks and other Scheduler tasks at the same level, like data processing. This adds a feature flag to disable passing a `timeout` option to Scheduler. React tasks will always append themselves to the end of the queue, without jumping ahead of already scheduled tasks. This does not affect the order in which React updates within a single root are processed, but it could affect updates across multiple roots. This also doesn't remove the expiration from Scheduler. It only means that React tasks are not given special treatment.
92 lines
2.7 KiB
JavaScript
92 lines
2.7 KiB
JavaScript
/**
|
|
* 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 typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
|
|
import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.www';
|
|
|
|
// Re-export dynamic flags from the www version.
|
|
export const {
|
|
debugRenderPhaseSideEffects,
|
|
debugRenderPhaseSideEffectsForStrictMode,
|
|
replayFailedUnitOfWorkWithInvokeGuardedCallback,
|
|
warnAboutDeprecatedLifecycles,
|
|
disableInputAttributeSyncing,
|
|
warnAboutShorthandPropertyCollision,
|
|
warnAboutDeprecatedSetNativeProps,
|
|
revertPassiveEffectsChange,
|
|
enableUserBlockingEvents,
|
|
disableLegacyContext,
|
|
disableSchedulerTimeoutBasedOnReactExpirationTime,
|
|
} = require('ReactFeatureFlags');
|
|
|
|
// In www, we have experimental support for gathering data
|
|
// from User Timing API calls in production. By default, we
|
|
// only emit performance.mark/measure calls in __DEV__. But if
|
|
// somebody calls addUserTimingListener() which is exposed as an
|
|
// experimental FB-only export, we call performance.mark/measure
|
|
// as long as there is more than a single listener.
|
|
export let enableUserTimingAPI = __DEV__;
|
|
|
|
export const enableProfilerTimer = __PROFILE__;
|
|
export const enableSchedulerTracing = __PROFILE__;
|
|
export const enableSchedulerDebugging = true;
|
|
|
|
export const enableStableConcurrentModeAPIs = false;
|
|
|
|
export const enableSuspenseServerRenderer = true;
|
|
|
|
export const disableJavaScriptURLs = true;
|
|
|
|
let refCount = 0;
|
|
export function addUserTimingListener() {
|
|
if (__DEV__) {
|
|
// Noop.
|
|
return () => {};
|
|
}
|
|
refCount++;
|
|
updateFlagOutsideOfReactCallStack();
|
|
return () => {
|
|
refCount--;
|
|
updateFlagOutsideOfReactCallStack();
|
|
};
|
|
}
|
|
|
|
// The flag is intentionally updated in a timeout.
|
|
// We don't support toggling it during reconciliation or
|
|
// commit since that would cause mismatching user timing API calls.
|
|
let timeout = null;
|
|
function updateFlagOutsideOfReactCallStack() {
|
|
if (!timeout) {
|
|
timeout = setTimeout(() => {
|
|
timeout = null;
|
|
enableUserTimingAPI = refCount > 0;
|
|
});
|
|
}
|
|
}
|
|
|
|
export const enableFlareAPI = true;
|
|
|
|
export const enableFundamentalAPI = false;
|
|
|
|
export const enableJSXTransformAPI = true;
|
|
|
|
export const warnAboutUnmockedScheduler = true;
|
|
|
|
export const enableSuspenseCallback = true;
|
|
|
|
export const warnAboutDefaultPropsOnFunctionComponents = false;
|
|
|
|
export const flushSuspenseFallbacksInTests = true;
|
|
|
|
// Flow magic to verify the exports of this file match the original version.
|
|
// eslint-disable-next-line no-unused-vars
|
|
type Check<_X, Y: _X, X: Y = _X> = null;
|
|
// eslint-disable-next-line no-unused-expressions
|
|
(null: Check<FeatureFlagsShimType, FeatureFlagsType>);
|