2015-12-01 11:31:31 +08:00
|
|
|
/**
|
2018-09-08 06:11:23 +08:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2015-12-01 11:31:31 +08:00
|
|
|
*
|
2017-09-25 04:48:13 +08:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-12-01 11:31:31 +08:00
|
|
|
*
|
2018-08-30 04:54:58 +08:00
|
|
|
* @flow strict
|
2015-12-01 11:31:31 +08:00
|
|
|
*/
|
|
|
|
|
|
2020-07-31 22:01:27 +08:00
|
|
|
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
|
|
|
|
// This prevents e.g. <img src=""> from making an unnecessary HTTP request for certain browsers.
|
|
|
|
|
export const enableFilterEmptyStringAttributesDOM = false;
|
|
|
|
|
|
2020-04-16 10:10:15 +08:00
|
|
|
// Adds verbose console logging for e.g. state updates, suspense, and work loop stuff.
|
|
|
|
|
// Intended to enable React core members to more easily debug scheduling issues in DEV builds.
|
|
|
|
|
export const enableDebugTracing = false;
|
|
|
|
|
|
2020-07-08 22:36:02 +08:00
|
|
|
// Adds user timing marks for e.g. state updates, suspense, and work loop stuff,
|
|
|
|
|
// for an experimental scheduling profiler tool.
|
2020-07-17 23:24:26 +08:00
|
|
|
export const enableSchedulingProfiler = __PROFILE__ && __EXPERIMENTAL__;
|
2020-07-08 22:36:02 +08:00
|
|
|
|
2019-11-05 06:07:05 +08:00
|
|
|
// Helps identify side effects in render-phase lifecycle hooks and setState
|
2021-02-25 05:14:14 +08:00
|
|
|
// reducers by double invoking them in StrictLegacyMode.
|
2018-01-26 06:30:53 +08:00
|
|
|
export const debugRenderPhaseSideEffectsForStrictMode = __DEV__;
|
|
|
|
|
|
2021-02-25 05:14:14 +08:00
|
|
|
// Helps identify code that is not safe for planned Offscreen API and Suspense semantics;
|
|
|
|
|
// this feature flag only impacts StrictEffectsMode.
|
|
|
|
|
export const enableStrictEffects = false;
|
|
|
|
|
|
2021-03-11 07:34:35 +08:00
|
|
|
// If TRUE, trees rendered with createRoot will be StrictEffectsMode.
|
2021-02-25 05:14:14 +08:00
|
|
|
// If FALSE, these trees will be StrictLegacyMode.
|
|
|
|
|
export const createRootStrictEffectsByDefault = false;
|
|
|
|
|
|
Add stack unwinding phase for handling errors (#12201)
* Add stack unwinding phase for handling errors
A rewrite of error handling, with semantics that more closely match
stack unwinding.
Errors that are thrown during the render phase unwind to the nearest
error boundary, like before. But rather than synchronously unmount the
children before retrying, we restart the failed subtree within the same
render phase. The failed children are still unmounted (as if all their
keys changed) but without an extra commit.
Commit phase errors are different. They work by scheduling an error on
the update queue of the error boundary. When we enter the render phase,
the error is popped off the queue. The rest of the algorithm is
the same.
This approach is designed to work for throwing non-errors, too, though
that feature is not implemented yet.
* Add experimental getDerivedStateFromCatch lifecycle
Fires during the render phase, so you can recover from an error within the same
pass. This aligns error boundaries more closely with try-catch semantics.
Let's keep this behind a feature flag until a future release. For now, the
recommendation is to keep using componentDidCatch. Eventually, the advice will
be to use getDerivedStateFromCatch for handling errors and componentDidCatch
only for logging.
* Reconcile twice to remount failed children, instead of using a boolean
* Handle effect immediately after its thrown
This way we don't have to store the thrown values on the effect list.
* ReactFiberIncompleteWork -> ReactFiberUnwindWork
* Remove startTime
* Remove TypeOfException
We don't need it yet. We'll reconsider once we add another exception type.
* Move replay to outer catch block
This moves it out of the hot path.
2018-02-24 09:38:42 +08:00
|
|
|
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
|
|
|
|
|
// replay the begin phase of a failed component inside invokeGuardedCallback.
|
|
|
|
|
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
|
|
|
|
|
|
2018-01-20 01:36:46 +08:00
|
|
|
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
|
2019-03-28 07:30:49 +08:00
|
|
|
export const warnAboutDeprecatedLifecycles = true;
|
2018-01-20 01:36:46 +08:00
|
|
|
|
2018-05-11 06:25:32 +08:00
|
|
|
// Gather advanced timing metrics for Profiler subtrees.
|
2018-06-12 04:16:27 +08:00
|
|
|
export const enableProfilerTimer = __PROFILE__;
|
2018-05-11 06:25:32 +08:00
|
|
|
|
2020-03-06 03:02:00 +08:00
|
|
|
// Record durations for commit and passive effects phases.
|
|
|
|
|
export const enableProfilerCommitHooks = false;
|
|
|
|
|
|
2020-11-10 22:40:30 +08:00
|
|
|
// Phase param passed to onRender callback differentiates between an "update" and a "cascading-update".
|
|
|
|
|
export const enableProfilerNestedUpdatePhase = false;
|
|
|
|
|
|
2020-11-12 22:31:27 +08:00
|
|
|
// Profiler API accepts a function to be called when a nested update is scheduled.
|
|
|
|
|
// This callback accepts the component type (class instance or function) the update is scheduled for.
|
|
|
|
|
export const enableProfilerNestedUpdateScheduledHook = false;
|
|
|
|
|
|
2021-04-09 22:34:33 +08:00
|
|
|
// Track which Fiber(s) schedule render work.
|
|
|
|
|
export const enableUpdaterTracking = __PROFILE__;
|
|
|
|
|
|
2019-10-16 06:09:19 +08:00
|
|
|
// SSR experiments
|
2021-05-12 23:28:14 +08:00
|
|
|
export const enableSuspenseServerRenderer = true;
|
|
|
|
|
export const enableSelectiveHydration = true;
|
2018-12-07 05:57:23 +08:00
|
|
|
|
2019-12-19 02:25:43 +08:00
|
|
|
// Flight experiments
|
2021-05-12 23:28:14 +08:00
|
|
|
export const enableLazyElements = true;
|
2020-12-03 11:44:56 +08:00
|
|
|
export const enableCache = __EXPERIMENTAL__;
|
2019-12-19 02:25:43 +08:00
|
|
|
|
2018-12-07 05:57:23 +08:00
|
|
|
// Only used in www builds.
|
2018-12-18 08:50:38 +08:00
|
|
|
export const enableSchedulerDebugging = false;
|
2018-09-06 06:04:59 +08:00
|
|
|
|
2019-03-12 07:39:49 +08:00
|
|
|
// Disable javascript: URL strings in href for XSS protection.
|
|
|
|
|
export const disableJavaScriptURLs = false;
|
|
|
|
|
|
2019-08-29 19:06:51 +08:00
|
|
|
// Experimental Scope support.
|
|
|
|
|
export const enableScopeAPI = false;
|
|
|
|
|
|
2020-05-13 02:01:12 +08:00
|
|
|
// Experimental Create Event Handle API.
|
|
|
|
|
export const enableCreateEventHandleAPI = false;
|
|
|
|
|
|
2019-04-08 03:02:34 +08:00
|
|
|
// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
|
2019-05-16 04:38:06 +08:00
|
|
|
|
2020-05-29 01:25:39 +08:00
|
|
|
// We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v18?)
|
2019-10-24 06:04:39 +08:00
|
|
|
// Till then, we warn about the missing mock, but still fallback to a legacy mode compatible version
|
2019-07-31 02:00:18 +08:00
|
|
|
export const warnAboutUnmockedScheduler = false;
|
2019-06-05 04:35:52 +08:00
|
|
|
|
2019-07-24 08:13:46 +08:00
|
|
|
// Add a callback property to suspense to notify which promises are currently
|
|
|
|
|
// in the update queue. This allows reporting and tracing of what is causing
|
|
|
|
|
// the user to see a loading state.
|
2019-08-20 04:26:39 +08:00
|
|
|
// Also allows hydration callbacks to fire when a dehydrated boundary gets
|
|
|
|
|
// hydrated or deleted.
|
2019-07-24 08:13:46 +08:00
|
|
|
export const enableSuspenseCallback = false;
|
2019-07-26 06:44:03 +08:00
|
|
|
|
|
|
|
|
// Part of the simplification of React.createElement so we can eventually move
|
|
|
|
|
// from React.createElement to React.jsx
|
|
|
|
|
// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
|
|
|
|
|
export const warnAboutDefaultPropsOnFunctionComponents = false;
|
2019-08-03 08:52:32 +08:00
|
|
|
|
|
|
|
|
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
|
2019-09-16 20:43:22 +08:00
|
|
|
|
|
|
|
|
export const enableTrustedTypesIntegration = false;
|
2019-11-12 03:35:29 +08:00
|
|
|
|
2020-02-20 19:30:04 +08:00
|
|
|
// Enables a warning when trying to spread a 'key' to an element;
|
|
|
|
|
// a deprecated pattern we want to get rid of in the future
|
|
|
|
|
export const warnAboutSpreadingKeyToJSX = false;
|
|
|
|
|
|
2020-06-12 10:13:13 +08:00
|
|
|
export const enableComponentStackLocations = true;
|
2020-04-07 06:43:39 +08:00
|
|
|
|
2020-03-13 02:38:32 +08:00
|
|
|
export const enableNewReconciler = false;
|
|
|
|
|
|
2020-12-02 23:25:55 +08:00
|
|
|
export const disableNativeComponentFrames = false;
|
|
|
|
|
|
2021-01-25 21:54:20 +08:00
|
|
|
// Errors that are thrown while unmounting (or after in the case of passive effects)
|
|
|
|
|
// should bypass any error boundaries that are also unmounting (or have unmounted)
|
|
|
|
|
// and be handled by the nearest still-mounted boundary.
|
|
|
|
|
// If there are no still-mounted boundaries, the errors should be rethrown.
|
|
|
|
|
export const skipUnmountedBoundaries = false;
|
|
|
|
|
|
2021-03-23 12:54:53 +08:00
|
|
|
// When a node is unmounted, recurse into the Fiber subtree and clean out
|
|
|
|
|
// references. Each level cleans up more fiber fields than the previous level.
|
|
|
|
|
// As far as we know, React itself doesn't leak, but because the Fiber contains
|
|
|
|
|
// cycles, even a single leak in product code can cause us to retain large
|
|
|
|
|
// amounts of memory.
|
|
|
|
|
//
|
|
|
|
|
// The long term plan is to remove the cycles, but in the meantime, we clear
|
|
|
|
|
// additional fields to mitigate.
|
|
|
|
|
//
|
|
|
|
|
// It's an enum so that we can experiment with different levels of
|
|
|
|
|
// aggressiveness.
|
|
|
|
|
export const deletedTreeCleanUpLevel = 1;
|
|
|
|
|
|
2021-04-06 21:21:02 +08:00
|
|
|
// Destroy layout effects for components that are hidden because something suspended in an update
|
|
|
|
|
// and recreate them when they are shown again (after the suspended boundary has resolved).
|
|
|
|
|
// Note that this should be an uncommon use case and can be avoided by using the transition API.
|
|
|
|
|
export const enableSuspenseLayoutEffectSemantics = false;
|
|
|
|
|
|
2020-01-20 23:00:18 +08:00
|
|
|
// --------------------------
|
|
|
|
|
// Future APIs to be deprecated
|
|
|
|
|
// --------------------------
|
|
|
|
|
|
|
|
|
|
// Prevent the value and checked attributes from syncing
|
|
|
|
|
// with their related DOM properties
|
|
|
|
|
export const disableInputAttributeSyncing = false;
|
|
|
|
|
|
|
|
|
|
export const warnAboutStringRefs = false;
|
|
|
|
|
|
|
|
|
|
export const disableLegacyContext = false;
|
|
|
|
|
|
2020-01-20 23:12:30 +08:00
|
|
|
// Disables children for <textarea> elements
|
|
|
|
|
export const disableTextareaChildren = false;
|
2020-01-22 05:17:42 +08:00
|
|
|
|
2020-03-07 02:46:32 +08:00
|
|
|
export const disableModulePatternComponents = false;
|
|
|
|
|
|
2020-01-30 19:56:04 +08:00
|
|
|
// We should remove this flag once the above flag becomes enabled
|
|
|
|
|
export const warnUnstableRenderSubtreeIntoContainer = false;
|
2020-01-22 05:17:42 +08:00
|
|
|
|
2020-03-05 07:41:59 +08:00
|
|
|
// Support legacy Primer support on internal FB www
|
2020-03-19 21:22:36 +08:00
|
|
|
export const enableLegacyFBSupport = false;
|
2020-05-07 10:19:14 +08:00
|
|
|
|
|
|
|
|
// Updates that occur in the render phase are not officially supported. But when
|
2020-06-12 11:05:15 +08:00
|
|
|
// they do occur, we defer them to a subsequent render by picking a lane that's
|
|
|
|
|
// not currently rendering. We treat them the same as if they came from an
|
|
|
|
|
// interleaved event. Remove this flag once we have migrated to the
|
|
|
|
|
// new behavior.
|
2020-05-07 10:19:14 +08:00
|
|
|
export const deferRenderPhaseUpdateToNextBatch = true;
|
2020-07-07 06:53:42 +08:00
|
|
|
|
2020-10-20 04:05:00 +08:00
|
|
|
export const enableUseRefAccessWarning = false;
|
2020-10-28 03:02:19 +08:00
|
|
|
|
|
|
|
|
export const enableRecursiveCommitTraversal = false;
|
2020-12-18 06:17:23 +08:00
|
|
|
|
|
|
|
|
export const disableSchedulerTimeoutInWorkLoop = false;
|
Experiment: Unsuspend all lanes on update (#20660)
Adds a feature flag to tweak the internal heuristic used to "unsuspend"
lanes when a new update comes in.
A lane is "suspended" if we couldn't finish rendering it because it was
missing data, and we chose not to commit the fallback. (In this context,
"suspended" does not include updates that finished with a fallback.)
When we receive new data in the form of an update, we need to retry
rendering the suspended lanes, since the new data may have unblocked the
previously suspended work. For example, the new update could navigate
back to an already loaded route.
It's impractical to retry every combination of suspended lanes, so we
need some heuristic that decides which lanes to retry and in
which order.
The existing heuristic roughly approximates the old Expiration Times
model. It unsuspends all lower priority lanes, but leaves higher
priority lanes suspended.
Then when we start rendering, we choose the lanes that have the highest
LanePriority and render those -- and then we add to that all the lanes
that are highher priority.
If this sounds terribly confusing, it's because it barely makes sense.
(It made more sense in the Expiration Times world, I promise, but it
was still confusing.) I don't think it's worth me trying to explain the
old behavior too much because the point here is that we can replace it
with something simpler.
The new heurstic is to unsuspend all suspended lanes whenever there's
an update.
This is effectively what we already do except in a few very specific
edge cases, ever since we removed the delayed suspense feature from
everything that's not a refresh transition.
We can optimize this in the future to only unsuspend lanes that are
either 1) in the `lanes` or `subtreeLanes` of the node that was updated,
or 2) in the `lanes` of the return path of the node that was updated.
This would exclude lanes that are only located in unrelated sibling
trees. But, this optimization wouldn't be useful currently because we
assign the same transition lane to all transitions. It will become
relevant again once we start assigning arbitrary lanes to transitions
-- but that in turn requires us to implement entanglement of overlapping
transitions, one of our planned projects.
So to sum up: the goal here is to remove the weird edge cases and switch
to a simpler model, on top of which we can make more substantial
improvements.
I put it behind a flag so I can run an A/B test and confirm it doesn't
cause a regression.
2021-01-27 04:23:34 +08:00
|
|
|
|
2021-02-26 06:42:11 +08:00
|
|
|
export const enableLazyContextPropagation = false;
|
2021-04-10 07:50:09 +08:00
|
|
|
|
|
|
|
|
export const enableSyncDefaultUpdates = true;
|
2021-04-29 04:09:30 +08:00
|
|
|
|
|
|
|
|
export const allowConcurrentByDefault = false;
|