prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
ffiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
// Renderers that don't support test selectors
// can re-export everything from this module.
function shim(...args: any): empty {
throw new Error(
'The curr... | dFiberRoot = shim;
export const getBoundingRect = shim;
export const getTextContent = shim;
export const isHiddenSubtree = shim;
export const matchAccessibilityRole = shim;
export const setFocusIfFocusable = shim;
export const setupIntersectionObserver = s | onst supportsTestSelectors = false;
export const fin | {
"filepath": "packages/react-reconciler/src/ReactFiberConfigWithNoTestSelectors.js",
"language": "javascript",
"file_size": 872,
"cut_index": 559,
"middle_length": 52
} |
ight (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
*/
// Renderers that don't support view transitions
// can re-export everything from this module.
function shim(...args: any): emp... | onst restoreRootViewTransitionName = shim;
export const cloneRootViewTransitionContainer = shim;
export const removeRootViewTransitionClone = shim;
export type InstanceMeasurement = any;
export const measureInstance = shim;
export const measureClonedInstan | w Transitions (when unsupported)
export const applyViewTransitionName = shim;
export const restoreViewTransitionName = shim;
export const cancelViewTransitionName = shim;
export const cancelRootViewTransitionName = shim;
export c | {
"filepath": "packages/react-reconciler/src/ReactFiberConfigWithNoViewTransition.js",
"language": "javascript",
"file_size": 1463,
"cut_index": 524,
"middle_length": 229
} |
om './ReactEventPriorities';
// import type {DevToolsProfilingHooks} from 'react-devtools-shared/src/backend/types';
// TODO: This import doesn't work because the DevTools depend on the DOM version of React
// and to properly type check against DOM React we can't also type check again non-DOM
// React which this hook m... | ckingSchedulerPriority,
NormalPriority as NormalSchedulerPriority,
IdlePriority as IdleSchedulerPriority,
log,
unstable_setDisableYieldValue,
} from './Scheduler';
declare const __REACT_DEVTOOLS_GLOBAL_HOOK__: Object | void;
let rendererID = null | ort {
DiscreteEventPriority,
ContinuousEventPriority,
DefaultEventPriority,
IdleEventPriority,
} from './ReactEventPriorities';
import {
ImmediatePriority as ImmediateSchedulerPriority,
UserBlockingPriority as UserBlo | {
"filepath": "packages/react-reconciler/src/ReactFiberDevToolsHook.js",
"language": "javascript",
"file_size": 14172,
"cut_index": 921,
"middle_length": 229
} |
iates.
*
* 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 {Fiber} from './ReactInternalTypes';
import type {ViewTransitionProps} from 'shared/ReactTypes';
import {runWithFiberInDEV} from './ReactCurrentFiber';
//... | ap<string, Fiber> = __DEV__
? new Map()
: (null: any);
const didWarnAboutName: {[string]: boolean} = __DEV__ ? {} : (null: any);
export function trackNamedViewTransition(fiber: Fiber): void {
if (__DEV__) {
const name = (fiber.memoizedProps: Vie | ts that can have separate namespaces, but to keep things
// simple we just use a global Map. Technically it should also include any manually
// assigned view-transition-name outside React too.
const mountedNamedViewTransitions: M | {
"filepath": "packages/react-reconciler/src/ReactFiberDuplicateViewTransitions.js",
"language": "javascript",
"file_size": 2696,
"cut_index": 563,
"middle_length": 229
} |
import type {Fiber, FiberRoot} from './ReactInternalTypes';
import type {CapturedValue} from './ReactCapturedValue';
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
import {ClassComponent} from './ReactWorkTags';
import reportGlobalError from 'shared/reportGlobalError';
impor... | se warnings e.g. for tests.
// See https://github.com/facebook/react/pull/13384
// For uncaught root errors we report them as uncaught to the browser's
// onerror callback. This won't have component stacks and the error addendum.
// So we add thos | t componentName: null | string = null;
let errorBoundaryName: null | string = null;
export function defaultOnUncaughtError(
error: mixed,
errorInfo: {+componentStack?: ?string},
): void {
// Overriding this can silence the | {
"filepath": "packages/react-reconciler/src/ReactFiberErrorLogger.js",
"language": "javascript",
"file_size": 6324,
"cut_index": 716,
"middle_length": 229
} |
import {
enableCreateEventHandleAPI,
enableEffectEventMutationPhase,
} from 'shared/ReactFeatureFlags';
export type Flags = number;
// Don't change these values. They're used by React Dev Tools.
export const NoFlags = /* */ 0b0000000000000000000000000000000;
export const PerformedWork = /* ... | 000000000100;
export const Cloned = /* */ 0b0000000000000000000000000001000;
export const ChildDeletion = /* */ 0b0000000000000000000000000010000;
export const ContentReset = /* */ 0b0000000000000000000 | 000000000000000000010000000;
export const Hydrating = /* */ 0b0000000000000000001000000000000;
// You can change the rest (and add more).
export const Update = /* */ 0b0000000000000000000 | {
"filepath": "packages/react-reconciler/src/ReactFiberFlags.js",
"language": "javascript",
"file_size": 7056,
"cut_index": 716,
"middle_length": 229
} |
sitionTypes} from 'react/src/ReactTransitionType';
import type {Lane} from './ReactFiberLane';
import {
GestureLane,
markRootEntangled,
markRootFinished,
NoLane,
NoLanes,
} from './ReactFiberLane';
import {
ensureRootIsScheduled,
requestTransitionLane,
} from './ReactFiberRootScheduler';
import {getCurre... | ate starts.
rangeEnd: number, // The percentage along the timeline where the "destination" state is reached.
types: null | TransitionTypes, // Any addTransitionType call made during startGestureTransition.
running: null | RunningViewTransition, // Us | estures.
export type ScheduledGesture = {
provider: GestureTimeline,
count: number, // The number of times this same provider has been started.
rangeStart: number, // The percentage along the timeline where the "current" st | {
"filepath": "packages/react-reconciler/src/ReactFiberGestureScheduler.js",
"language": "javascript",
"file_size": 9312,
"cut_index": 921,
"middle_length": 229
} |
iates.
*
* 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 {Fiber} from './ReactInternalTypes';
import type {StackCursor} from './ReactFiberStack';
import type {Lanes} from './ReactFiberLane';
import {createCursor... | nes` context from work loop in favor of this one.
baseLanes: number,
...
};
// TODO: This isn't being used yet, but it's intended to replace the
// InvisibleParentContext that is currently managed by SuspenseContext.
export const currentTreeHiddenStac | TODO: Remove `renderLanes` context in favor of hidden context
type HiddenContext = {
// Represents the lanes that must be included when processing updates in
// order to reveal the hidden content.
// TODO: Remove `subtreeLa | {
"filepath": "packages/react-reconciler/src/ReactFiberHiddenContext.js",
"language": "javascript",
"file_size": 2710,
"cut_index": 563,
"middle_length": 229
} |
ate: () => (() => void) | void,
deps: Array<mixed> | void | null,
next: Effect,
};
type StoreInstance<T> = {
value: T,
getSnapshot: () => T,
};
type StoreConsistencyCheck<T> = {
value: T,
getSnapshot: () => T,
};
type EventFunctionPayload<Args, Return, F: (...Array<Args>) => Return> = {
ref: {
even... | anes;
// The work-in-progress fiber. I've named it differently to distinguish it from
// the work-in-progress hook.
let currentlyRenderingFiber: Fiber = (null: any);
// Hooks are stored as a linked list on the fiber's memoizedState field. The
// current h | ray<StoreConsistencyCheck<any>> | null,
memoCache: MemoCache | null,
};
type BasicStateAction<S> = (S => S) | S;
type Dispatch<A> = A => void;
// These are set right before calling the component.
let renderLanes: Lanes = NoL | {
"filepath": "packages/react-reconciler/src/ReactFiberHooks.js",
"language": "javascript",
"file_size": 174561,
"cut_index": 7068,
"middle_length": 229
} |
import type {Fiber} from './ReactInternalTypes';
import type {StackCursor} from './ReactFiberStack';
import type {
Container,
HostContext,
TransitionStatus,
} from './ReactFiberConfig';
import type {Hook} from './ReactFiberHooks';
import {
getChildHostContext,
getRootHostContext,
HostTransitionContext,
N... | vider (in React DOM, a <form />)
// NOTE: Since forms cannot be nested, and this feature is only implemented by
// React DOM, we don't technically need this to be a stack. It could be a single
// module variable instead.
const hostTransitionProviderCursor: | reateCursor(null);
const contextFiberStackCursor: StackCursor<Fiber | null> = createCursor(null);
const rootInstanceStackCursor: StackCursor<Container | null> =
createCursor(null);
// Represents the nearest host transition pro | {
"filepath": "packages/react-reconciler/src/ReactFiberHostContext.js",
"language": "javascript",
"file_size": 6220,
"cut_index": 716,
"middle_length": 229
} |
'shared/ReactTypes';
import {
flushSyncWork,
scheduleUpdateOnFiber,
flushPendingEffects,
} from './ReactFiberWorkLoop';
import {enqueueConcurrentRenderForLane} from './ReactFiberConcurrentUpdates';
import {updateContainerSync} from './ReactFiberReconciler';
import {emptyContextObject} from './ReactFiberLegacyCo... |
// Resolves type to a family.
type RefreshHandler = any => Family | void;
// Used by React Refresh runtime through DevTools Global Hook.
export type SetRefreshHandler = (handler: RefreshHandler | null) => void;
export type ScheduleRefresh = (root: FiberR | ACT_FORWARD_REF_TYPE,
REACT_MEMO_TYPE,
REACT_LAZY_TYPE,
} from 'shared/ReactSymbols';
export type Family = {
current: any,
};
export type RefreshUpdate = {
staleFamilies: Set<Family>,
updatedFamilies: Set<Family>,
};
| {
"filepath": "packages/react-reconciler/src/ReactFiberHotReloading.js",
"language": "javascript",
"file_size": 9457,
"cut_index": 921,
"middle_length": 229
} |
onent,
} from './ReactWorkTags';
import {createCapturedValueAtFiber} from './ReactCapturedValue';
import {createFiberFromDehydratedFragment} from './ReactFiber';
import {
shouldSetTextContent,
supportsHydration,
supportsSingletons,
getNextHydratableSibling,
getNextHydratableSiblingAfterSingleton,
getFirst... | atableInstanceAfterActivityInstance,
getNextHydratableInstanceAfterSuspenseInstance,
shouldDeleteUnhydratedTailInstances,
resolveSingletonInstance,
canHydrateInstance,
canHydrateTextInstance,
canHydrateActivityInstance,
canHydrateSuspenseInst | leton,
hydrateInstance,
diffHydratedPropsForDevWarnings,
describeHydratableInstanceForDevWarnings,
hydrateTextInstance,
diffHydratedTextForDevWarnings,
hydrateActivityInstance,
hydrateSuspenseInstance,
getNextHydr | {
"filepath": "packages/react-reconciler/src/ReactFiberHydrationContext.js",
"language": "javascript",
"file_size": 30478,
"cut_index": 1331,
"middle_length": 229
} |
Fiber,
children: Array<HydrationDiffNode>,
serverProps: void | null | $ReadOnly<{[propName: string]: mixed}> | string, // null means no matching server node
serverTail: Array<
| $ReadOnly<{type: string, props: $ReadOnly<{[propName: string]: mixed}>}>
| string,
>,
distanceFromLeaf: number,
};
const ma... | const child = node.children[0];
return findNotableNode(child, indent);
}
return node;
}
function indentation(indent: number): string {
return ' ' + ' '.repeat(indent);
}
function added(indent: number): string {
return '+ ' + ' '.repeat( | rverTail.length === 0 &&
node.children.length === 1 &&
node.distanceFromLeaf > 3 &&
node.distanceFromLeaf > idealDepth - indent
) {
// This is not an interesting node for contextual purposes so we can skip it.
| {
"filepath": "packages/react-reconciler/src/ReactFiberHydrationDiffs.js",
"language": "javascript",
"file_size": 19599,
"cut_index": 1331,
"middle_length": 229
} |
e: Lane = /* */ 0b0000000000000000000000000000010;
export const SyncLaneIndex: number = 1;
export const InputContinuousHydrationLane: Lane = /* */ 0b0000000000000000000000000000100;
export const InputContinuousLane: Lane = /* */ 0b0000000000000000000000000001000;
export const Def... | 0000000000000000010000000;
const TransitionLanes: Lanes = /* */ 0b0000000001111111111111100000000;
const TransitionLane1: Lane = /* */ 0b0000000000000000000000100000000;
const TransitionLane2: Lane = /* | dateLanes: Lane =
SyncLane | InputContinuousLane | DefaultLane;
export const GestureLane: Lane = /* */ 0b0000000000000000000000001000000;
const TransitionHydrationLane: Lane = /* */ 0b000000 | {
"filepath": "packages/react-reconciler/src/ReactFiberLane.js",
"language": "javascript",
"file_size": 44446,
"cut_index": 2151,
"middle_length": 229
} |
./ReactWorkTags';
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
import {createCursor, push, pop} from './ReactFiberStack';
let warnedAboutMissingGetChildContext;
if (__DEV__) {
warnedAboutMissingGetChildContext = ({}: {[string]: boolean});
}
export const emptyContextObjec... | stack.
// We use this to get access to the parent context after we have already
// pushed the next context provider, and now need to merge their contexts.
let previousContext: Object = emptyContextObject;
function getUnmaskedContext(
workInProgress: Fib | (emptyContextObject);
// A cursor to a boolean indicating whether the context has changed.
const didPerformWorkStackCursor: StackCursor<boolean> = createCursor(false);
// Keep track of the previous context object that was on the | {
"filepath": "packages/react-reconciler/src/ReactFiberLegacyContext.js",
"language": "javascript",
"file_size": 9866,
"cut_index": 921,
"middle_length": 229
} |
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 {
enableDefaultTransitionIndicator,
enableViewTransition,
} from 'shared/ReactFeatureFlags';
export let rootMutationContext: bool... | Context;
viewTransitionMutationContext = false;
return prev;
}
export function popMutationContext(prev: boolean): void {
if (enableViewTransition) {
if (viewTransitionMutationContext) {
rootMutationContext = true;
}
viewTransitionM | alse;
}
if (enableViewTransition) {
viewTransitionMutationContext = false;
}
}
export function pushMutationContext(): boolean {
if (!enableViewTransition) {
return false;
}
const prev = viewTransitionMutation | {
"filepath": "packages/react-reconciler/src/ReactFiberMutationTracking.js",
"language": "javascript",
"file_size": 1550,
"cut_index": 537,
"middle_length": 229
} |
geLanes} from './ReactFiberLane';
import {
NoFlags,
DidPropagateContext,
NeedsPropagation,
} from './ReactFiberFlags';
import is from 'shared/objectIs';
import {getHostTransitionProvider} from './ReactFiberHostContext';
const valueCursor: StackCursor<mixed> = createCursor(null);
let rendererCursorDEV: StackCur... | null = null;
let isDisallowedContextReadInDEV: boolean = false;
export function resetContextDependencies(): void {
// This is called right before React yields execution, to ensure `readContext`
// cannot be called outside the render phase.
currentl | let rendererSigil;
if (__DEV__) {
// Use this to detect multiple renderers using the same context
rendererSigil = {};
}
let currentlyRenderingFiber: Fiber | null = null;
let lastContextDependency: ContextDependency<mixed> | | {
"filepath": "packages/react-reconciler/src/ReactFiberNewContext.js",
"language": "javascript",
"file_size": 20438,
"cut_index": 1331,
"middle_length": 229
} |
iates.
*
* 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 {ReactNodeList, Wakeable} from 'shared/ReactTypes';
import type {Lanes} from './ReactFiberLane';
import type {SpawnedCachePool} from './ReactFiberCacheComp... | ps = {
// TODO: Pick an API before exposing the Offscreen type. I've chosen an enum
// for now, since we might have multiple variants. For example, hiding the
// content without changing the layout.
//
// Default mode is visible. Kind of a weird | erSuspenseComponent';
type OffscreenMode = 'hidden' | 'unstable-defer-without-hiding' | 'visible';
export type LegacyHiddenProps = {
mode?: OffscreenMode | null | void,
children?: ReactNodeList,
};
export type OffscreenPro | {
"filepath": "packages/react-reconciler/src/ReactFiberOffscreenComponent.js",
"language": "javascript",
"file_size": 2132,
"cut_index": 563,
"middle_length": 229
} |
rtsUserTiming) {
// Ensure we create all tracks in priority order. Currently performance.mark() are in
// first insertion order but performance.measure() are in the reverse order. We can
// always add the 0 time slot even if it's in the past. That's still considered for
// ordering.
console.timeStam... |
LANES_TRACK_GROUP,
'primary-light',
);
console.timeStamp(
'Suspense Track',
0.003,
0.003,
'Suspense',
LANES_TRACK_GROUP,
'primary-light',
);
console.timeStamp(
'Idle Track',
0.003 | 'Gesture Track',
0.003,
0.003,
'Gesture',
LANES_TRACK_GROUP,
'primary-light',
);
}
console.timeStamp(
'Transition Track',
0.003,
0.003,
'Transition', | {
"filepath": "packages/react-reconciler/src/ReactFiberPerformanceTrack.js",
"language": "javascript",
"file_size": 44540,
"cut_index": 2151,
"middle_length": 229
} |
tFiberWithNoPortals,
} from './ReactFiberTreeReflection';
import {get as getInstance} from 'shared/ReactInstanceMap';
import {
HostComponent,
HostSingleton,
ClassComponent,
HostRoot,
SuspenseComponent,
ActivityComponent,
} from './ReactWorkTags';
import getComponentNameFromFiber from 'react-reconciler/src/g... | tObject,
isContextProvider as isLegacyContextProvider,
} from './ReactFiberLegacyContext';
import {createFiberRoot} from './ReactFiberRoot';
import {isRootDehydrated} from './ReactFiberShellHydration';
import {
injectInternals,
markRenderScheduled,
| shared/ReactSharedInternals';
import {
getPublicInstance,
rendererVersion,
rendererPackageName,
extraDevToolsConfig,
} from './ReactFiberConfig';
import {
findCurrentUnmaskedContext,
processChildContext,
emptyContex | {
"filepath": "packages/react-reconciler/src/ReactFiberReconciler.js",
"language": "javascript",
"file_size": 27830,
"cut_index": 1331,
"middle_length": 229
} |
import type {ReactNodeList, ReactFormState} from 'shared/ReactTypes';
import type {
FiberRoot,
SuspenseHydrationCallbacks,
TransitionTracingCallbacks,
} from './ReactInternalTypes';
import type {RootTag} from './ReactRootTags';
import type {Cache} from './ReactFiberCacheComponent';
import type {Container} from '.... | ansition,
enableDefaultTransitionIndicator,
} from 'shared/ReactFeatureFlags';
import {initializeUpdateQueue} from './ReactFiberClassUpdateQueue';
import {LegacyRoot, ConcurrentRoot} from './ReactRootTags';
import {createCache, retainCache} from './React |
} from './ReactFiberLane';
import {
enableSuspenseCallback,
enableProfilerCommitHooks,
enableProfilerTimer,
enableUpdaterTracking,
enableTransitionTracing,
disableLegacyMode,
enableViewTransition,
enableGestureTr | {
"filepath": "packages/react-reconciler/src/ReactFiberRoot.js",
"language": "javascript",
"file_size": 6780,
"cut_index": 716,
"middle_length": 229
} |
tNextLanes,
includesSyncLane,
markStarvedLanesAsExpired,
claimNextTransitionUpdateLane,
getNextLanesToFlushSync,
checkIfRootIsPrerendering,
isGestureRender,
} from './ReactFiberLane';
import {
CommitContext,
NoContext,
RenderContext,
flushPendingEffects,
flushPendingEffectsDelayed,
getExecutionC... | ty as NormalSchedulerPriority,
IdlePriority as IdleSchedulerPriority,
cancelCallback as Scheduler_cancelCallback,
scheduleCallback as Scheduler_scheduleCallback,
now,
} from './Scheduler';
import {
DiscreteEventPriority,
ContinuousEventPriority | ,
performWorkOnRoot,
} from './ReactFiberWorkLoop';
import {LegacyRoot} from './ReactRootTags';
import {
ImmediatePriority as ImmediateSchedulerPriority,
UserBlockingPriority as UserBlockingSchedulerPriority,
NormalPriori | {
"filepath": "packages/react-reconciler/src/ReactFiberRootScheduler.js",
"language": "javascript",
"file_size": 27637,
"cut_index": 1331,
"middle_length": 229
} |
import type {Fiber} from './ReactInternalTypes';
import type {
ReactScopeInstance,
ReactContext,
ReactScopeQuery,
} from 'shared/ReactTypes';
import {
getPublicInstance,
getInstanceFromNode,
getInstanceFromScope,
} from './ReactFiberConfig';
import {isFiberSuspenseAndTimedOut} from './ReactFiberTreeReflect... | ScopeAPI) {
if (node.tag === HostComponent) {
const {type, memoizedProps, stateNode} = node;
const instance = getPublicInstance(stateNode);
if (
instance !== null &&
fn(type, memoizedProps || emptyObject, instance) === | : Fiber | null {
return ((((fiber.child: any): Fiber).sibling: any): Fiber).child;
}
const emptyObject = {};
function collectScopedNodes(
node: Fiber,
fn: ReactScopeQuery,
scopedNodes: Array<any>,
): void {
if (enable | {
"filepath": "packages/react-reconciler/src/ReactFiberScope.js",
"language": "javascript",
"file_size": 5212,
"cut_index": 716,
"middle_length": 229
} |
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 {Fiber} from './ReactInternalTypes';
export type StackCursor<T> = {current: T};
const valueStack: Array<any>... | ) {
console.error('Unexpected Fiber popped.');
}
}
cursor.current = valueStack[index];
valueStack[index] = null;
if (__DEV__) {
fiberStack[index] = null;
}
index--;
}
function push<T>(cursor: StackCursor<T>, value: T, fiber: | alue,
};
}
function pop<T>(cursor: StackCursor<T>, fiber: Fiber): void {
if (index < 0) {
if (__DEV__) {
console.error('Unexpected pop.');
}
return;
}
if (__DEV__) {
if (fiber !== fiberStack[index] | {
"filepath": "packages/react-reconciler/src/ReactFiberStack.js",
"language": "javascript",
"file_size": 1184,
"cut_index": 518,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {Wakeable, SuspenseListTailMode} from 'shared/ReactTypes';
import type {Fiber} from './ReactInternalTypes';
import type {SuspenseInstance} from './ReactFiberConfig';
import type {Lane} from './ReactFiberLan... | .
// A non-null SuspenseState means that it is blocked for one reason or another.
// - A non-null dehydrated field means it's blocked pending hydration.
// - A non-null dehydrated field can use isSuspenseInstancePending or
// isSuspenseInstanceFallba | ;
import {NoFlags, DidCapture} from './ReactFiberFlags';
import {
isSuspenseInstancePending,
isSuspenseInstanceFallback,
} from './ReactFiberConfig';
// A null SuspenseState represents an unsuspended normal Suspense boundary | {
"filepath": "packages/react-reconciler/src/ReactFiberSuspenseComponent.js",
"language": "javascript",
"file_size": 3792,
"cut_index": 614,
"middle_length": 229
} |
import type {SuspenseProps} from 'shared/ReactTypes';
import type {Fiber} from './ReactInternalTypes';
import type {StackCursor} from './ReactFiberStack';
import type {SuspenseState} from './ReactFiberSuspenseComponent';
import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
import {createCursor, pu... | visible in the current tree.
// Everything above this is the "shell". When this is null, it means we're
// rendering in the shell of the app. If it's non-null, it means we're rendering
// deeper than the shell, inside a new tree that wasn't already visible | hat should capture if something
// suspends, i.e. it's the nearest `catch` block on the stack.
const suspenseHandlerStackCursor: StackCursor<Fiber | null> =
createCursor(null);
// Represents the outermost boundary that is not | {
"filepath": "packages/react-reconciler/src/ReactFiberSuspenseContext.js",
"language": "javascript",
"file_size": 9024,
"cut_index": 716,
"middle_length": 229
} |
;
import {callLazyInitInDEV} from './ReactFiberCallUserSpace';
import {getWorkInProgressRoot} from './ReactFiberWorkLoop';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import {enableAsyncDebugInfo} from 'shared/ReactFeatureFlags';
import noop from 'shared/noop';
opaque type ThenableStateDev = {... | state: any);
return prodState;
}
}
// An error that is thrown (e.g. by `use`) to trigger Suspense. If we
// detect this is caught by userspace, we'll log a warning in development.
export const SuspenseException: mixed = new Error(
"Suspense Except | nableStateProd;
function getThenablesFromState(state: ThenableState): Array<Thenable<any>> {
if (__DEV__) {
const devState: ThenableStateDev = (state: any);
return devState.thenables;
} else {
const prodState = ( | {
"filepath": "packages/react-reconciler/src/ReactFiberThenable.js",
"language": "javascript",
"file_size": 15702,
"cut_index": 921,
"middle_length": 229
} |
FunctionComponent,
ForwardRef,
SimpleMemoComponent,
ActivityComponent,
SuspenseComponent,
OffscreenComponent,
SuspenseListComponent,
} from './ReactWorkTags';
import {
DidCapture,
Incomplete,
NoFlags,
ShouldCapture,
LifecycleEffectMask,
ForceUpdateForLegacySuspense,
ForceClientRender,
Sch... | yForHotReloading} from './ReactFiberHotReloading';
import {
getShellBoundary,
getSuspenseHandler,
} from './ReactFiberSuspenseContext';
import {
renderDidError,
queueConcurrentError,
renderDidSuspendDelayIfPossible,
markLegacyErrorBoundaryAsFai | rt {createCapturedValueAtFiber} from './ReactCapturedValue';
import {
enqueueCapturedUpdate,
createUpdate,
CaptureUpdate,
ForceUpdate,
enqueueUpdate,
} from './ReactFiberClassUpdateQueue';
import {markFailedErrorBoundar | {
"filepath": "packages/react-reconciler/src/ReactFiberThrow.js",
"language": "javascript",
"file_size": 27590,
"cut_index": 1331,
"middle_length": 229
} |
tFiberOffscreenComponent';
import type {StackCursor} from './ReactFiberStack';
import {enableTransitionTracing} from 'shared/ReactFeatureFlags';
import {createCursor, push, pop} from './ReactFiberStack';
import {getWorkInProgressTransitions} from './ReactFiberWorkLoop';
export type SuspenseInfo = {name: string | null... | sition>},
> | null,
markerComplete: Map<string, Set<Transition>> | null,
};
// TODO: Is there a way to not include the tag or name here?
export type TracingMarkerInstance = {
tag?: TracingMarkerTag,
transitions: Set<Transition> | null,
pendingBo | ion> | null,
markerProgress: Map<
string,
{pendingBoundaries: PendingBoundaries, transitions: Set<Transition>},
> | null,
markerIncomplete: Map<
string,
{aborts: Array<TransitionAbort>, transitions: Set<Tran | {
"filepath": "packages/react-reconciler/src/ReactFiberTracingMarkerComponent.js",
"language": "javascript",
"file_size": 9280,
"cut_index": 921,
"middle_length": 229
} |
ffiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
// Renderers that don't support test selectors
// can re-export everything from this module.
function shim(...args: any): empty {
throw new Error(
'react-no... | FiberRoot = shim;
export const getBoundingRect = shim;
export const getTextContent = shim;
export const isHiddenSubtree = shim;
export const matchAccessibilityRole = shim;
export const setFocusIfFocusable = shim;
export const setupIntersectionObserver = sh | nst supportsTestSelectors = false;
export const find | {
"filepath": "packages/react-noop-renderer/src/ReactFiberConfigNoopTestSelectors.js",
"language": "javascript",
"file_size": 871,
"cut_index": 559,
"middle_length": 52
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
/**
* This is a renderer of React that doesn't have a render target output.
* It is useful to demonstrate the internals of the reconciler in isolation
* and for testing semantics of reconciliation separate from the ... | FlowFixMe[prop-missing]
ReactFlightClient({
createStringDecoder() {
return new TextDecoder();
},
readPartialStringChunk(decoder: TextDecoder, buffer: Uint8Array): string {
return decoder.decode(buffer, decoderOptions);
},
| ght-modules';
import ReactFlightClient from 'react-client/flight';
type Source = Array<Uint8Array>;
const decoderOptions = {stream: true};
const {createResponse, createStreamState, processBinaryChunk, getRoot, close} =
// $ | {
"filepath": "packages/react-noop-renderer/src/ReactNoopFlightClient.js",
"language": "javascript",
"file_size": 3602,
"cut_index": 614,
"middle_length": 229
} |
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
*/
/**
* This is a renderer of React that doesn't have a render target output.
* It is useful to demonstrate the internals of the reconciler i... | dingChildrenAsJSX,
getSuspenseyThingStatus,
resolveSuspenseyThing,
resetSuspenseyThingCache,
createPortal,
render,
renderLegacySyncRoot,
renderToRootWithID,
unmountRootWithID,
findInstance,
flushNextYield,
startTrackingHostCounters,
| eReactNoop';
export const {
_Scheduler,
getChildren,
dangerouslyGetChildren,
getPendingChildren,
dangerouslyGetPendingChildren,
getOrCreateRootContainer,
createRoot,
createLegacyRoot,
getChildrenAsJSX,
getPen | {
"filepath": "packages/react-noop-renderer/src/ReactNoopPersistent.js",
"language": "javascript",
"file_size": 1509,
"cut_index": 537,
"middle_length": 229
} |
ight (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 {Fiber} from './ReactInternalTypes';
import {getStackByFiberInDevAndProd} from './ReactFiberComponentStack';
const... | null) {
const existing = CapturedStacks.get(value);
if (existing !== undefined) {
return existing;
}
const captured: CapturedValue<T> = {
value,
source,
stack: getStackByFiberInDevAndProd(source),
};
Capture | turedValueAtFiber<T>(
value: T,
source: Fiber,
): CapturedValue<T> {
// If the value is an error, call this function immediately after it is thrown
// so the stack is accurate.
if (typeof value === 'object' && value !== | {
"filepath": "packages/react-reconciler/src/ReactCapturedValue.js",
"language": "javascript",
"file_size": 1461,
"cut_index": 524,
"middle_length": 229
} |
= debugInfo[i];
const debugTask: ?ConsoleTask = componentInfo.debugTask;
if (debugTask != null) {
return debugTask;
}
}
}
}
}
return null;
}
let didWarnAboutMaps;
let didWarnAboutGenerators;
let ownerHasKeyUseWarning;
let ownerHasFunctionTypeWarning;
let ... | tring]: boolean});
ownerHasFunctionTypeWarning = ({}: {[string]: boolean});
ownerHasSymbolTypeWarning = ({}: {[string]: boolean});
warnForMissingKey = (
returnFiber: Fiber,
workInProgress: Fiber,
child: mixed,
) => {
if (child === | s = false;
/**
* Warn if there's no key explicitly set on dynamic arrays of children or
* object keys are not valid. This allows us to keep track of children between
* updates.
*/
ownerHasKeyUseWarning = ({}: {[s | {
"filepath": "packages/react-reconciler/src/ReactChildFiber.js",
"language": "javascript",
"file_size": 73521,
"cut_index": 3790,
"middle_length": 229
} |
pe {ViewTransitionState} from './ReactFiberViewTransitionComponent';
import type {TracingMarkerInstance} from './ReactFiberTracingMarkerComponent';
import {
supportsResources,
supportsSingletons,
isHostHoistableType,
isHostSingletonType,
} from './ReactFiberConfig';
import {
enableProfilerTimer,
enableScop... | stSingleton,
ForwardRef,
Fragment,
Mode,
ContextProvider,
ContextConsumer,
Profiler,
SuspenseComponent,
SuspenseListComponent,
DehydratedFragment,
FunctionComponent,
MemoComponent,
SimpleMemoComponent,
LazyComponent,
ScopeCompon | tureFlags';
import {NoFlags, Placement, StaticMask} from './ReactFiberFlags';
import {ConcurrentRoot} from './ReactRootTags';
import {
ClassComponent,
HostRoot,
HostComponent,
HostText,
HostPortal,
HostHoistable,
Ho | {
"filepath": "packages/react-reconciler/src/ReactFiber.js",
"language": "javascript",
"file_size": 28377,
"cut_index": 1331,
"middle_length": 229
} |
ource code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {ActivityInstance} from './ReactFiberConfig';
import type {CapturedValue} from './ReactCapturedValue';
import type {Lane} from './ReactFiberLane';
import type {TreeContext} f... | o hydrate a dehydrated boundary at.
// OffscreenLane is the default for dehydrated boundaries.
// NoLane is the default for normal boundaries, which turns into "normal" pri.
retryLane: Lane,
// Stashed Errors that happened while attempting to hydra | ontext,
// Represents the lane we should attempt t | {
"filepath": "packages/react-reconciler/src/ReactFiberActivityComponent.js",
"language": "javascript",
"file_size": 966,
"cut_index": 582,
"middle_length": 52
} |
./ReactWorkTags';
import {
restoreEnterOrExitViewTransitions,
restoreNestedViewTransitions,
restoreUpdateViewTransitionForGesture,
appearingViewTransitions,
commitEnterViewTransitions,
measureNestedViewTransitions,
measureUpdateViewTransition,
viewTransitionCancelableChildren,
pushViewTransitionCancel... | kAnimatingTask} from './ReactProfilerTimer';
import {scheduleGestureTransitionEvent} from './ReactFiberWorkLoop';
// Used during the apply phase to track whether a parent ViewTransition component
// might have been affected by any mutations / relayouts be | s';
import {
getViewTransitionName,
getViewTransitionClassName,
} from './ReactFiberViewTransitionComponent';
import {
enableProfilerTimer,
enableComponentPerformanceTrack,
} from 'shared/ReactFeatureFlags';
import {trac | {
"filepath": "packages/react-reconciler/src/ReactFiberApplyGesture.js",
"language": "javascript",
"file_size": 48743,
"cut_index": 2151,
"middle_length": 229
} |
ntext';
import {
constructClassInstance,
mountClassInstance,
resumeMountClassInstance,
updateClassInstance,
resolveClassComponentProps,
} from './ReactFiberClassComponent';
import {
createFiberFromTypeAndProps,
createFiberFromFragment,
createFiberFromOffscreen,
createWorkInProgress,
isSimpleFunction... |
createCapturedValueFromError,
createCapturedValueAtFiber,
} from './ReactCapturedValue';
import {OffscreenVisible} from './ReactFiberOffscreenComponent';
import {
createClassErrorUpdate,
initializeClassErrorUpdate,
} from './ReactFiberThrow';
impo | InProgressRoot,
peekDeferredLane,
} from './ReactFiberWorkLoop';
import {enqueueConcurrentRenderForLane} from './ReactFiberConcurrentUpdates';
import {pushCacheProvider, CacheContext} from './ReactFiberCacheComponent';
import { | {
"filepath": "packages/react-reconciler/src/ReactFiberBeginWork.js",
"language": "javascript",
"file_size": 153168,
"cut_index": 7068,
"middle_length": 229
} |
import type {Fiber} from './ReactInternalTypes';
import type {LazyComponent} from 'react/src/ReactLazy';
import type {Effect} from './ReactFiberHooks';
import type {CapturedValue} from './ReactCapturedValue';
import {isRendering, setIsRendering} from './ReactCurrentFiber';
import {captureCommitPhaseError} from './Reac... | try {
const result = Component(props, secondArg);
return result;
} finally {
setIsRendering(wasRendering);
}
},
};
export const callComponentInDEV: <Props, Arg, R>(
Component: (p: Props, arg: Arg) => R,
props: Props,
seco | callComponent = {
react_stack_bottom_frame: function <Props, Arg, R>(
Component: (p: Props, arg: Arg) => R,
props: Props,
secondArg: Arg,
): R {
const wasRendering = isRendering;
setIsRendering(true);
| {
"filepath": "packages/react-reconciler/src/ReactFiberCallUserSpace.js",
"language": "javascript",
"file_size": 6545,
"cut_index": 716,
"middle_length": 229
} |
yContext';
import {readContext, checkIfContextChanged} from './ReactFiberNewContext';
import {requestUpdateLane, scheduleUpdateOnFiber} from './ReactFiberWorkLoop';
import {
markForceUpdateScheduled,
markStateUpdateScheduled,
setIsStrictModeForDevtools,
} from './ReactFiberDevToolsHook';
import {startUpdateTimerB... | didWarnAboutChildContextTypes;
let didWarnAboutInvalidateContextType;
let didWarnOnInvalidCallback;
if (__DEV__) {
didWarnAboutStateAssignmentForComponent = new Set<string>();
didWarnAboutUninitializedState = new Set<string>();
didWarnAboutGetSnaps | ithoutDidUpdate;
let didWarnAboutLegacyLifecyclesAndDerivedState;
let didWarnAboutUndefinedDerivedState;
let didWarnAboutDirectlyAssigningPropsToState;
let didWarnAboutContextTypeAndContextTypes;
let didWarnAboutContextTypes;
let | {
"filepath": "packages/react-reconciler/src/ReactFiberClassComponent.js",
"language": "javascript",
"file_size": 41425,
"cut_index": 2151,
"middle_length": 229
} |
ainer,
insertBefore,
insertInContainerBefore,
replaceContainerChildren,
hideDehydratedBoundary,
hideInstance,
hideTextInstance,
unhideDehydratedBoundary,
unhideInstance,
unhideTextInstance,
commitHydratedInstance,
commitHydratedContainer,
commitHydratedActivityInstance,
commitHydratedSuspenseI... | enableFragmentRefs,
enableFragmentRefsTextNodes,
} from 'shared/ReactFeatureFlags';
export function commitHostMount(finishedWork: Fiber) {
const type = finishedWork.type;
const props = finishedWork.memoizedProps;
const instance: Instance = finishe | tance,
} from './ReactFiberConfig';
import {captureCommitPhaseError} from './ReactFiberWorkLoop';
import {trackHostMutation} from './ReactFiberMutationTracking';
import {runWithFiberInDEV} from './ReactCurrentFiber';
import {
| {
"filepath": "packages/react-reconciler/src/ReactFiberCommitHostEffects.js",
"language": "javascript",
"file_size": 21665,
"cut_index": 1331,
"middle_length": 229
} |
seBoundary,
commitShowHideHostInstance,
commitShowHideHostTextInstance,
commitHostPlacement,
commitHostRootContainerChildren,
commitHostPortalContainerChildren,
commitHostHydratedContainer,
commitHostHydratedActivity,
commitHostHydratedSuspense,
commitHostRemoveChildFromContainer,
commitHostRemoveCh... | n,
restoreNestedViewTransitions,
measureUpdateViewTransition,
measureNestedViewTransitions,
resetAppearingViewTransitions,
trackAppearingViewTransition,
viewTransitionCancelableChildren,
pushViewTransitionCancelableScope,
popViewTransitionC | import {
trackEnterViewTransitions,
commitEnterViewTransitions,
commitExitViewTransitions,
commitBeforeUpdateViewTransition,
commitNestedViewTransitions,
restoreEnterOrExitViewTransitions,
restoreUpdateViewTransitio | {
"filepath": "packages/react-reconciler/src/ReactFiberCommitWork.js",
"language": "javascript",
"file_size": 181301,
"cut_index": 7068,
"middle_length": 229
} |
import {enableViewTransition} from 'shared/ReactFeatureFlags';
import type {Fiber} from './ReactInternalTypes';
import type {ReactComponentInfo} from 'shared/ReactTypes';
import {
HostComponent,
HostHoistable,
HostSingleton,
LazyComponent,
SuspenseComponent,
SuspenseListComponent,
FunctionComponent,
Fo... | er: null | Fiber): string {
switch (fiber.tag) {
case HostHoistable:
case HostSingleton:
case HostComponent:
return describeBuiltInComponentFrame(fiber.type);
case LazyComponent:
// TODO: When we support Thenables as component | ctionComponentFrame,
describeClassComponentFrame,
describeDebugInfoFrame,
} from 'shared/ReactComponentStackFrame';
import {formatOwnerStack} from 'shared/ReactOwnerStackFrames';
function describeFiber(fiber: Fiber, childFib | {
"filepath": "packages/react-reconciler/src/ReactFiberComponentStack.js",
"language": "javascript",
"file_size": 7450,
"cut_index": 716,
"middle_length": 229
} |
iates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
// Renderers that don't support hydration
// can re-export everything from this module.
function shim(...args: any): empty {
throw new Error(
'The current rende... | Details = shim;
export const registerSuspenseInstanceRetry = shim;
export const canHydrateFormStateMarker = shim;
export const isFormStateMarkerMatching = shim;
export const getNextHydratableSibling = shim;
export const getNextHydratableSiblingAfterSinglet | e = mixed;
export type SuspenseInstance = mixed;
export const supportsHydration = false;
export const isSuspenseInstancePending = shim;
export const isSuspenseInstanceFallback = shim;
export const getSuspenseInstanceFallbackError | {
"filepath": "packages/react-reconciler/src/ReactFiberConfigWithNoHydration.js",
"language": "javascript",
"file_size": 2735,
"cut_index": 563,
"middle_length": 229
} |
ight (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
*/
/**
* This is a renderer of React that doesn't have a render target output.
* It is useful to demonstrate the internals of the... | JSX,
getPendingChildrenAsJSX,
getSuspenseyThingStatus,
resolveSuspenseyThing,
resetSuspenseyThingCache,
createPortal,
render,
renderLegacySyncRoot,
renderToRootWithID,
unmountRootWithID,
findInstance,
flushNextYield,
startTrackingHo | from './createReactNoop';
export const {
_Scheduler,
getChildren,
dangerouslyGetChildren,
getPendingChildren,
dangerouslyGetPendingChildren,
getOrCreateRootContainer,
createRoot,
createLegacyRoot,
getChildrenAs | {
"filepath": "packages/react-noop-renderer/src/ReactNoop.js",
"language": "javascript",
"file_size": 1435,
"cut_index": 524,
"middle_length": 229
} |
ate from the host
* environment.
*/
import type {ReactNodeList} from 'shared/ReactTypes';
import ReactFizzServer from 'react-server';
type Instance = {
type: string,
children: Array<Instance | TextInstance | SuspenseInstance>,
prop: any,
hidden: boolean,
};
type TextInstance = {
text: string,
hidden: ... | };
type Destination = {
root: null | Instance | TextInstance | SuspenseInstance,
placeholders: Map<number, Placeholder>,
segments: Map<number, Segment>,
stack: Array<Segment | Instance | SuspenseInstance>,
};
type ResumableState = null;
type Rend | n: Array<Instance | TextInstance | SuspenseInstance>,
};
type Placeholder = {
parent: Instance | Segment | SuspenseInstance,
index: number,
};
type Segment = {
children: Array<Instance | TextInstance | SuspenseInstance>,
| {
"filepath": "packages/react-noop-renderer/src/ReactNoopServer.js",
"language": "javascript",
"file_size": 9878,
"cut_index": 921,
"middle_length": 229
} |
iates.
*
* 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 {Fiber} from './ReactInternalTypes';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import {getOwnerStackByFiberInDev} from './ReactFiber... | NameFromOwner(owner);
}
}
return null;
}
function getCurrentFiberStackInDev(): string {
if (__DEV__) {
if (current === null) {
return '';
}
// Safe because if current fiber exists, we are reconciling,
// and it is guarantee | xport function getCurrentFiberOwnerNameInDevOrNull(): string | null {
if (__DEV__) {
if (current === null) {
return null;
}
const owner = current._debugOwner;
if (owner != null) {
return getComponent | {
"filepath": "packages/react-reconciler/src/ReactCurrentFiber.js",
"language": "javascript",
"file_size": 2691,
"cut_index": 563,
"middle_length": 229
} |
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 {Lane, Lanes} from './ReactFiberLane';
import {
NoLane,
SyncLane,
InputContinuousLane,
DefaultLane,
IdleLane,
getHig... | e;
export function higherEventPriority(
a: EventPriority,
b: EventPriority,
): EventPriority {
return a !== 0 && a < b ? a : b;
}
export function lowerEventPriority(
a: EventPriority,
b: EventPriority,
): EventPriority {
return a === 0 || a > | riority: EventPriority = SyncLane;
export const ContinuousEventPriority: EventPriority = InputContinuousLane;
export const DefaultEventPriority: EventPriority = DefaultLane;
export const IdleEventPriority: EventPriority = IdleLan | {
"filepath": "packages/react-reconciler/src/ReactEventPriorities.js",
"language": "javascript",
"file_size": 1680,
"cut_index": 537,
"middle_length": 229
} |
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 {AsyncDispatcher, Fiber} from './ReactInternalTypes';
import type {Cache} from './ReactFiberCacheComponent';
... | cache.data.set(resourceType, cacheForType);
}
return cacheForType;
}
function cacheSignal(): null | AbortSignal {
const cache: Cache = readContext(CacheContext);
return cache.controller.signal;
}
export const DefaultAsyncDispatcher: AsyncDispatch | Type<T>(resourceType: () => T): T {
const cache: Cache = readContext(CacheContext);
let cacheForType: T | void = (cache.data.get(resourceType): any);
if (cacheForType === undefined) {
cacheForType = resourceType();
| {
"filepath": "packages/react-reconciler/src/ReactFiberAsyncDispatcher.js",
"language": "javascript",
"file_size": 1160,
"cut_index": 518,
"middle_length": 229
} |
update in the persistent list that hasn't been processed.
// The work-in-progress pointer always has a position equal to or greater than
// the current queue, since we always work on that one. The current queue's
// pointer is only updated during the commit phase, when we swap in the
// work-in-progress.
//
// For exa... | rocessing them. For example, if we only add updates to
// the work-in-progress queue, some updates could be lost whenever a work-in
// -progress render restarts by cloning from current. Similarly, if we only add
// updates to the current queue, the updates | The work-in-progress queue has
// processed more updates than current.
//
// The reason we append to both queues is because otherwise we might drop
// updates without ever p | {
"filepath": "packages/react-reconciler/src/ReactFiberClassUpdateQueue.js",
"language": "javascript",
"file_size": 26417,
"cut_index": 1331,
"middle_length": 229
} |
nableProfilerNestedUpdatePhase,
enableSchedulingProfiler,
enableViewTransition,
enableFragmentRefs,
} from 'shared/ReactFeatureFlags';
import {
ClassComponent,
Fragment,
HostComponent,
HostHoistable,
HostSingleton,
ViewTransitionComponent,
} from './ReactWorkTags';
import {NoFlags} from './ReactFiberF... |
import {
getPublicInstance,
createViewTransitionInstance,
createFragmentInstance,
} from './ReactFiberConfig';
import {
captureCommitPhaseError,
setIsRunningInsertionEffect,
} from './ReactFiberWorkLoop';
import {
NoFlags as NoHookEffect,
La | ation,
startEffectTimer,
isCurrentUpdateNested,
} from './ReactProfilerTimer';
import {NoMode, ProfileMode} from './ReactTypeOfMode';
import {
commitCallbacks,
commitHiddenCallbacks,
} from './ReactFiberClassUpdateQueue'; | {
"filepath": "packages/react-reconciler/src/ReactFiberCommitEffects.js",
"language": "javascript",
"file_size": 32150,
"cut_index": 1331,
"middle_length": 229
} |
as ClassUpdate,
} from './ReactFiberClassUpdateQueue';
import type {Lane, Lanes} from './ReactFiberLane';
import type {OffscreenInstance} from './ReactFiberOffscreenComponent';
import {
warnAboutUpdateOnNotYetMountedFiberInDEV,
throwIfInfiniteUpdateLoopDetected,
getWorkInProgressRoot,
} from './ReactFiberWorkLo... | / If a render is in progress, and we receive an update from a concurrent event,
// we wait until the current render is over (either finished or interrupted)
// before adding it to the fiber/hook queue. Push to this array so we can
// access the queue, fibe | './ReactWorkTags';
import {OffscreenVisible} from './ReactFiberOffscreenComponent';
export type ConcurrentUpdate = {
next: ConcurrentUpdate,
lane: Lane,
};
type ConcurrentQueue = {
pending: ConcurrentUpdate | null,
};
/ | {
"filepath": "packages/react-reconciler/src/ReactFiberConcurrentUpdates.js",
"language": "javascript",
"file_size": 10310,
"cut_index": 921,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
/**
* This is a renderer of React that doesn't have a render target output.
* It is useful to demonstrate the internals of the reconciler in isolation
* and for testing semantics of reconciliation separate from the ... | void) {
callback();
},
scheduleWork(callback: () => void) {
callback();
},
beginWriting(destination: Destination): void {},
writeChunk(destination: Destination, chunk: string): void {
destination.push(chunk);
},
writeChunkAndRetur | om 'react-server/flight';
type Destination = Array<Uint8Array | string>;
const textEncoder = new TextEncoder();
// $FlowFixMe[prop-missing]
const ReactNoopFlightServer = ReactFlightServer({
scheduleMicrotask(callback: () => | {
"filepath": "packages/react-noop-renderer/src/ReactNoopFlightServer.js",
"language": "javascript",
"file_size": 3853,
"cut_index": 614,
"middle_length": 229
} |
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 {Fiber} from './ReactFiber';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import {warnsIfNotActing} from './... | -name] Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global
typeof IS_REACT_ACT_ENVIRONMENT !== 'undefined'
? // $FlowFixMe[cannot-resolve-name]
IS_REACT_ACT_ENVIRONMENT
: undefined;
// $FlowFixMe[cannot-resolve-name | vironment whenever `jest` is defined, but you can still turn off
// spurious warnings by setting IS_REACT_ACT_ENVIRONMENT explicitly
// to false.
const isReactActEnvironmentGlobal =
// $FlowFixMe[cannot-resolve | {
"filepath": "packages/react-reconciler/src/ReactFiberAct.js",
"language": "javascript",
"file_size": 1961,
"cut_index": 537,
"middle_length": 229
} |
import type {
Thenable,
FulfilledThenable,
RejectedThenable,
} from 'shared/ReactTypes';
import type {Lane} from './ReactFiberLane';
import type {Transition} from 'react/src/ReactStartTransition';
import {
requestTransitionLane,
ensureScheduleIsScheduled,
} from './ReactFiberRootScheduler';
import {NoLane} f... | balError';
// If there are multiple, concurrent async actions, they are entangled. All
// transition updates that occur while the async action is still in progress
// are treated as part of the action.
//
// The ideal behavior would be to treat each async | enableDefaultTransitionIndicator,
} from 'shared/ReactFeatureFlags';
import {clearEntangledAsyncTransitionTypes} from './ReactFiberTransitionTypes';
import noop from 'shared/noop';
import reportGlobalError from 'shared/reportGlo | {
"filepath": "packages/react-reconciler/src/ReactFiberAsyncAction.js",
"language": "javascript",
"file_size": 8926,
"cut_index": 716,
"middle_length": 229
} |
erHiddenContext';
import {findFirstSuspended} from './ReactFiberSuspenseComponent';
import {
isContextProvider as isLegacyContextProvider,
popContext as popLegacyContext,
popTopLevelContextObject as popTopLevelLegacyContextObject,
} from './ReactFiberLegacyContext';
import {popProvider} from './ReactFiberNewConte... | ons,
shouldRemainOnPreviousScreen,
markSpawnedRetryLane,
} from './ReactFiberWorkLoop';
import {
OffscreenLane,
SomeRetryLane,
NoLanes,
includesSomeLane,
mergeLanes,
claimNextRetryLane,
includesOnlySuspenseyCommitEligibleLanes,
} from './ | drationState,
getIsHydrating,
upgradeHydrationErrorsToRecoverable,
emitPendingHydrationWarnings,
} from './ReactFiberHydrationContext';
import {
renderHasNotSuspendedYet,
getRenderTargetTime,
getWorkInProgressTransiti | {
"filepath": "packages/react-reconciler/src/ReactFiberCompleteWork.js",
"language": "javascript",
"file_size": 77185,
"cut_index": 3790,
"middle_length": 229
} |
ared/ReactSymbols';
import isArray from 'shared/isArray';
import {checkPropStringCoercion} from 'shared/CheckStringCoercion';
import {
NoEventPriority,
DiscreteEventPriority,
DefaultEventPriority,
IdleEventPriority,
ConcurrentRoot,
LegacyRoot,
} from 'react-reconciler/constants';
import * as DefaultConfig f... |
unstable_transitionCallbacks?: TransitionTracingCallbacks,
onUncaughtError?: (
error: mixed,
errorInfo: {+componentStack: ?string},
) => void,
onCaughtError?: (
error: mixed,
errorInfo: {
+componentStack: ?string,
+erro | ctVersion';
type Props = {
prop: any,
hidden: boolean,
children?: mixed,
bottom?: null | number,
left?: null | number,
right?: null | number,
top?: null | number,
src?: string,
...
};
type CreateRootOptions = { | {
"filepath": "packages/react-noop-renderer/src/createReactNoop.js",
"language": "javascript",
"file_size": 47264,
"cut_index": 2151,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {ReactContext} from 'shared/ReactTypes';
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
import {REACT_CONTEXT_TYPE} from 'shared/ReactSymbols';
import {pushProvider, popProvider} from... | rShim() {
const listeners = [];
const signal = (this.signal = {
aborted: false as boolean,
addEventListener: (type, listener) => {
listeners.push(listener);
},
});
this.abort = () = | use.
const AbortControllerLocal: typeof AbortController =
typeof AbortController !== 'undefined'
? AbortController
: // $FlowFixMe[incompatible-type]
// $FlowFixMe[missing-this-annot]
function AbortControlle | {
"filepath": "packages/react-reconciler/src/ReactFiberCacheComponent.js",
"language": "javascript",
"file_size": 3500,
"cut_index": 614,
"middle_length": 229
} |
irs in the beforeMutation phase.
export let appearingViewTransitions: Map<string, ViewTransitionState> | null =
null;
export function resetAppearingViewTransitions(): void {
appearingViewTransitions = null;
}
export function trackAppearingViewTransition(
name: string,
state: ViewTransitionState,
): void {
i... | n immediate child, then that will trigger as an "Enter" in future passes.
// We don't do anything else for that case in the "before mutation" phase but we
// still have to mark it as needing to call startViewTransition if nothing else
// update | ): void {
if (
placement.tag === ViewTransitionComponent ||
(placement.subtreeFlags & ViewTransitionStatic) !== NoFlags
) {
// If an inserted or appearing Fiber is a ViewTransition component or has one as
// a | {
"filepath": "packages/react-reconciler/src/ReactFiberCommitViewTransitions.js",
"language": "javascript",
"file_size": 34501,
"cut_index": 2151,
"middle_length": 229
} |
ight (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
*/
// Renderers that don't support mutation
// can re-export everything from this module.
function shim(...args: any): empty {
t... | mitTextUpdate = shim;
export const commitMount = shim;
export const commitUpdate = shim;
export const insertBefore = shim;
export const insertInContainerBefore = shim;
export const removeChild = shim;
export const removeChildFromContainer = shim;
export co | pported)
export const supportsMutation = false;
export const cloneMutableInstance = shim;
export const cloneMutableTextInstance = shim;
export const appendChild = shim;
export const appendChildToContainer = shim;
export const com | {
"filepath": "packages/react-reconciler/src/ReactFiberConfigWithNoMutation.js",
"language": "javascript",
"file_size": 1302,
"cut_index": 524,
"middle_length": 229
} |
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
*/
export type WorkTag =
| 0
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| 13
| 14
| 15
| 16
| 17
|... | gment = 7;
export const Mode = 8;
export const ContextConsumer = 9;
export const ContextProvider = 10;
export const ForwardRef = 11;
export const Profiler = 12;
export const SuspenseComponent = 13;
export const MemoComponent = 14;
export const SimpleMemoCo | // Root of a host tree. Could be nested inside another node.
export const HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
export const HostComponent = 5;
export const HostText = 6;
export const Fra | {
"filepath": "packages/react-reconciler/src/ReactWorkTags.js",
"language": "javascript",
"file_size": 1599,
"cut_index": 537,
"middle_length": 229
} |
acheForType;
caches = [];
seededCache = null;
});
function createTextCache() {
if (seededCache !== null) {
// Trick to seed a cache before it exists.
// TODO: Need a built-in API to seed data before the initial render (i.e.
// not a refresh because nothing has mounted yet).
con... | d);
} else if (record.status === 'pending') {
const thenable = record.value;
record.status = 'resolved';
record.value = text;
thenable.pings.forEach(t => t());
}
},
reject(text, error) {
| resolve(text) {
const record = data.get(text);
if (record === undefined) {
const newRecord = {
status: 'resolved',
value: text,
};
data.set(text, newRecor | {
"filepath": "packages/react-reconciler/src/__tests__/ReactContextPropagation-test.js",
"language": "javascript",
"file_size": 30817,
"cut_index": 1331,
"middle_length": 229
} |
waitForPaint;
describe('ReactDefaultTransitionIndicator', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
const InternalTestUtils = require('internal-test-utils');
act = InternalTestUtils... | let resolve;
const promise = new Promise(r => (resolve = r));
function App() {
return use(promise);
}
const root = ReactNoop.createRoot({
onDefaultTransitionIndicator() {
Scheduler.log('start');
return () => {
| e;
useTransition = React.useTransition;
useDeferredValue = React.useDeferredValue;
});
// @gate enableDefaultTransitionIndicator
it('triggers the default indicator while a transition is on-going', async () => {
| {
"filepath": "packages/react-reconciler/src/__tests__/ReactDefaultTransitionIndicator-test.js",
"language": "javascript",
"file_size": 11192,
"cut_index": 921,
"middle_length": 229
} |
Scheduler.log(`Suspend! [${text}]`);
throw record.value;
case 'rejected':
throw record.value;
case 'resolved':
return record.value;
}
} else {
Scheduler.log(`Suspend! [${text}]`);
const thenable = {
pings: [],
then(resolve) {
... | eturn text;
}
function AsyncText({text}) {
readText(text);
Scheduler.log(text);
return text;
}
it('does not cause an infinite defer loop if the original value isn\t memoized', async () => {
function App({value}) {
// The obj | },
};
const newRecord = {
status: 'pending',
value: thenable,
};
textCache.set(text, newRecord);
throw thenable;
}
}
function Text({text}) {
Scheduler.log(text);
r | {
"filepath": "packages/react-reconciler/src/__tests__/ReactDeferredValue-test.js",
"language": "javascript",
"file_size": 35145,
"cut_index": 2151,
"middle_length": 229
} |
iates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @jest-environment node
*/
'use strict';
let React;
let ReactNoop;
let Scheduler;
let act;
let useEffect;
let useLayoutEffect;
let assertLog;
describe('R... | InternalTestUtils.assertLog;
});
it('layout unmounts on deletion are fired in parent -> child order', async () => {
const root = ReactNoop.createRoot();
function Parent() {
useLayoutEffect(() => {
return () => Scheduler.log('Unm | r = require('scheduler');
act = require('internal-test-utils').act;
useEffect = React.useEffect;
useLayoutEffect = React.useLayoutEffect;
const InternalTestUtils = require('internal-test-utils');
assertLog = | {
"filepath": "packages/react-reconciler/src/__tests__/ReactEffectOrdering-test.js",
"language": "javascript",
"file_size": 2110,
"cut_index": 563,
"middle_length": 229
} |
let rootCaughtErrors = [];
let SomethingThatErrors;
let CatchingBoundary;
let onCaughtError;
beforeEach(function () {
jest.resetModules();
React = require('react');
Suspense = React.Suspense;
Activity = React.Activity;
ViewTransition = React.ViewTransition;
ReactNoop = require('react... | rStack())
: null,
);
};
SomethingThatErrors = () => {
throw new Error('uh oh');
};
// eslint-disable-next-line no-shadow
CatchingBoundary = class CatchingBoundary extends React.Component {
constructor() {
| tError = function (error, errorInfo) {
rootCaughtErrors.push(
error.message,
normalizeCodeLocInfo(errorInfo.componentStack),
React.captureOwnerStack
? normalizeCodeLocInfo(React.captureOwne | {
"filepath": "packages/react-reconciler/src/__tests__/ReactErrorStacks-test.js",
"language": "javascript",
"file_size": 9351,
"cut_index": 921,
"middle_length": 229
} |
tils = require('internal-test-utils');
assertLog = InternalTestUtils.assertLog;
waitFor = InternalTestUtils.waitFor;
waitForAll = InternalTestUtils.waitForAll;
unstable_waitForExpired = InternalTestUtils.unstable_waitForExpired;
const textCache = new Map();
readText = text => {
const rec... |
status: 'pending',
ping: ping,
promise,
};
textCache.set(text, newRecord);
throw promise;
}
};
resolveText = text => {
const record = textCache.get(text);
if (record !== unde | throw Error('Failed to load: ' + text);
case 'resolved':
return text;
}
} else {
let ping;
const promise = new Promise(resolve => (ping = resolve));
const newRecord = { | {
"filepath": "packages/react-reconciler/src/__tests__/ReactExpiration-test.js",
"language": "javascript",
"file_size": 22649,
"cut_index": 1331,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @jest-environment node
*/
'use strict';
let React;
let act;
let ReactFiberReconciler;
let ConcurrentRoot;
let DefaultEventPriority;
let NoEventPriority;
describe('ReactFiberHostContext', () => {
before... | ).NoEventPriority;
});
global.IS_REACT_ACT_ENVIRONMENT = true;
// @gate __DEV__
it('should send the context to prepareForCommit and resetAfterCommit', () => {
const rootContext = {};
const childContext = {};
let updatePriority: typeof | ciler/src/ReactRootTags').ConcurrentRoot;
DefaultEventPriority =
require('react-reconciler/src/ReactEventPriorities').DefaultEventPriority;
NoEventPriority =
require('react-reconciler/src/ReactEventPriorities' | {
"filepath": "packages/react-reconciler/src/__tests__/ReactFiberHostContext-test.internal.js",
"language": "javascript",
"file_size": 3804,
"cut_index": 614,
"middle_length": 229
} |
MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
'use strict';
let React;
let Scheduler;
let ReactNoop;
let act;
let assertLog;
describe('ReactFiberRefs', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
Scheduler... | ops or state
return false;
}
render() {
Scheduler.log('Render');
component = this;
return 'Hi';
}
}
const ref1 = React.createRef();
const ref2 = React.createRef();
const root = ReactNoop.cr | f is attached even if there are no other updates (class)', async () => {
let component;
class Component extends React.Component {
shouldComponentUpdate() {
// This component's output doesn't depend on any pr | {
"filepath": "packages/react-reconciler/src/__tests__/ReactFiberRefs-test.js",
"language": "javascript",
"file_size": 4830,
"cut_index": 614,
"middle_length": 229
} |
require('react-dom/client');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
useState = React.useState;
useEffect = React.useEffect;
startTransition = React.startTransition;
const InternalTestUtils = require('internal-test-utils');
assertLog = InternalTestUtils.a... | gName !== 'SCRIPT' && node.tagName !== 'script') ||
node.hasAttribute('data-meaningful')) &&
node.tagName !== 'TEMPLATE' &&
node.tagName !== 'template' &&
!node.hasAttribute('hidden') &&
!node.hasAttribut | return text;
}
function getVisibleChildren(element: Element): React$Node {
const children = [];
let node: any = element.firstChild;
while (node) {
if (node.nodeType === 1) {
if (
((node.ta | {
"filepath": "packages/react-reconciler/src/__tests__/ReactFlushSync-test.js",
"language": "javascript",
"file_size": 10646,
"cut_index": 921,
"middle_length": 229
} |
Microtask;
let flushFakeMicrotasks;
// TODO: Migrate tests to React DOM instead of React Noop
describe('ReactFlushSync (AggregateError not available)', () => {
beforeEach(() => {
jest.resetModules();
global.AggregateError = undefined;
// When AggregateError is not available, the errors are rethrown in... | shFakeMicrotasks = () => {
while (fakeMicrotaskQueue.length > 0) {
const cb = fakeMicrotaskQueue.shift();
cb();
}
};
React = require('react');
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom | sk = false;
const fakeMicrotaskQueue = [];
global.queueMicrotask = cb => {
if (overrideQueueMicrotask) {
fakeMicrotaskQueue.push(cb);
} else {
originalQueueMicrotask(cb);
}
};
flu | {
"filepath": "packages/react-reconciler/src/__tests__/ReactFlushSyncNoAggregateError-test.js",
"language": "javascript",
"file_size": 4567,
"cut_index": 614,
"middle_length": 229
} |
ReactNoop.render(element);
await waitForAll([]);
expect(ReactNoop).toMatchRenderedOutput(<span>foo</span>);
});
it('should render zero children via noop renderer', async () => {
const element = <React.Fragment />;
ReactNoop.render(element);
await waitForAll([]);
expect(ReactNoop).t... | > {
const element = (
<>{new Set([<span key="a">hi</span>, <span key="b">bye</span>])}</>
);
ReactNoop.render(element);
await waitForAll([]);
expect(ReactNoop).toMatchRenderedOutput(
<>
<span>hi</span>
<spa | ReactNoop.render(element);
await waitForAll([]);
expect(ReactNoop).toMatchRenderedOutput(
<>
hello <span>world</span>
</>,
);
});
it('should render an iterable via noop renderer', async () = | {
"filepath": "packages/react-reconciler/src/__tests__/ReactFragment-test.js",
"language": "javascript",
"file_size": 23507,
"cut_index": 1331,
"middle_length": 229
} |
or one of the following reasons:\n' +
'1. You might have mismatching versions of React and the renderer (such as React DOM)\n' +
'2. You might be breaking the Rules of Hooks\n' +
'3. You might have more than one copy of React in the same app\n' +
'See https://react.dev/link/inval... | State(0);
setCounter1 = _setCounter1;
const [counter2, _setCounter2] = useState(0);
setCounter2 = _setCounter2;
const text = `${counter1}, ${counter2}`;
Scheduler.log(`Parent: ${text}`);
useLayoutEffect(() => {
| useLayoutEffect} = React;
function Child({text}) {
Scheduler.log('Child: ' + text);
return text;
}
let setCounter1;
let setCounter2;
function Parent() {
const [counter1, _setCounter1] = use | {
"filepath": "packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js",
"language": "javascript",
"file_size": 64923,
"cut_index": 2151,
"middle_length": 229
} |
k works properly.
function GoodCounter(props, ref) {
const [count] = useState(props.initialCount);
return <Text text={count} />;
}
ReactNoop.render(<GoodCounter initialCount={10} />);
await waitForAll([10]);
});
it('throws when called outside the render phase', async () => {
expect(... | f Hooks\n' +
'3. You might have more than one copy of React in the same app\n' +
'See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.',
]);
});
describe('useState', () => {
it('simple | ion component. This could happen for' +
' one of the following reasons:\n' +
'1. You might have mismatching versions of React and the renderer (such as React DOM)\n' +
'2. You might be breaking the Rules o | {
"filepath": "packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js",
"language": "javascript",
"file_size": 136105,
"cut_index": 7068,
"middle_length": 229
} |
der and Content.
await waitForAll([
'Foo',
'Content',
'firstRenderCallbackCalled',
'secondRenderCallbackCalled',
]);
});
it('can cancel partially rendered work and restart', async () => {
function Bar(props) {
Scheduler.log('Bar');
return <div>{props.children}</div>;... | or(['Foo', 'Bar']);
// This will abort the previous work and restart
ReactNoop.flushSync(() => ReactNoop.render(null));
React.startTransition(() => {
ReactNoop.render(<Foo text="baz" />);
});
// Flush part of the new work
a | // Init
ReactNoop.render(<Foo text="foo" />);
await waitForAll(['Foo', 'Bar', 'Bar']);
React.startTransition(() => {
ReactNoop.render(<Foo text="bar" />);
});
// Flush part of the work
await waitF | {
"filepath": "packages/react-reconciler/src/__tests__/ReactIncremental-test.js",
"language": "javascript",
"file_size": 81386,
"cut_index": 3790,
"middle_length": 229
} |
t-hiding' : mode}>
{children}
</React.unstable_LegacyHidden>
</div>
);
}
it('recovers from errors asynchronously', async () => {
class ErrorBoundary extends React.Component {
state = {error: null};
static getDerivedStateFromError(error) {
Scheduler.log('getDerive... | ht an error: ${error.message}`} />;
}
function Indirection({children}) {
Scheduler.log('Indirection');
return children || null;
}
function BadRender({unused}) {
Scheduler.log('throw');
throw new Error('oops!');
| .state.error} />;
}
Scheduler.log('ErrorBoundary (try)');
return this.props.children;
}
}
function ErrorMessage({error}) {
Scheduler.log('ErrorMessage');
return <span prop={`Caug | {
"filepath": "packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js",
"language": "javascript",
"file_size": 54819,
"cut_index": 2151,
"middle_length": 229
} |
re because we want to observe how errors are reported for real.
await cb();
Scheduler.unstable_flushAll();
}
describe('ReactIncrementalErrorLogging', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('schedule... | arn = jest.fn();
console.error = jest.fn();
uncaughtExceptionMock = jest.fn();
process.on('uncaughtException', uncaughtExceptionMock);
});
afterEach(() => {
console.warn = oldConsoleWarn;
console.error = oldConsoleError;
proces | hers
// because they filter out precisely the messages we want to test for.
let oldConsoleWarn;
let oldConsoleError;
beforeEach(() => {
oldConsoleWarn = console.warn;
oldConsoleError = console.error;
console.w | {
"filepath": "packages/react-reconciler/src/__tests__/ReactIncrementalErrorLogging-test.js",
"language": "javascript",
"file_size": 10583,
"cut_index": 921,
"middle_length": 229
} |
port type {StackCursor} from './ReactFiberStack';
import type {Cache, SpawnedCachePool} from './ReactFiberCacheComponent';
import type {Transition} from 'react/src/ReactStartTransition';
import type {ScheduledGesture} from './ReactFiberGestureScheduler';
import {
enableTransitionTracing,
enableViewTransition,
en... | ntangleAsyncTransitionTypes,
entangledTransitionTypes,
} from './ReactFiberTransitionTypes';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import {
entangleAsyncAction,
peekEntangledActionLane,
} from './ReactFiberAsyncAction';
imp | rogressRoot,
getWorkInProgressTransitions,
markTransitionStarted,
} from './ReactFiberWorkLoop';
import {
createCache,
retainCache,
CacheContext,
} from './ReactFiberCacheComponent';
import {
queueTransitionTypes,
e | {
"filepath": "packages/react-reconciler/src/ReactFiberTransition.js",
"language": "javascript",
"file_size": 11908,
"cut_index": 921,
"middle_length": 229
} |
sequence that represent the position of the child within the
// current level of children.
//
// 00101 00010001011010101
// ╰─┬─╯ ╰───────┬───────╯
// Fork 5 of 20 Parent id
//
// The leading 0s are important. In the above example, you only need 3 bits to
// represent slot 5. However, you... | he
// sequence. It's treated as a transparent indirection. For example, these two
// trees produce the same ids:
//
// <> <>
// <Indirection> <A />
// <A /> <B />
// </Indirection> | se,
// the zeroth id at a level would be indistinguishable from its parent.
//
// If a node has only one child, and does not materialize an id (i.e. does not
// contain a useId hook), then we don't need to allocate any space in t | {
"filepath": "packages/react-reconciler/src/ReactFiberTreeContext.js",
"language": "javascript",
"file_size": 10072,
"cut_index": 921,
"middle_length": 229
} |
ctivityComponent';
import type {
SuspenseState,
SuspenseListRenderState,
} from './ReactFiberSuspenseComponent';
import type {Cache} from './ReactFiberCacheComponent';
import type {TracingMarkerInstance} from './ReactFiberTracingMarkerComponent';
import {
ClassComponent,
HostRoot,
HostComponent,
HostHoista... | nTracing,
} from 'shared/ReactFeatureFlags';
import {popHostContainer, popHostContext} from './ReactFiberHostContext';
import {
popSuspenseListContext,
popSuspenseHandler,
} from './ReactFiberSuspenseContext';
import {popHiddenContext} from './ReactFi | cingMarkerComponent,
} from './ReactWorkTags';
import {DidCapture, NoFlags, ShouldCapture, Update} from './ReactFiberFlags';
import {NoMode, ProfileMode} from './ReactTypeOfMode';
import {
enableProfilerTimer,
enableTransitio | {
"filepath": "packages/react-reconciler/src/ReactFiberUnwindWork.js",
"language": "javascript",
"file_size": 10940,
"cut_index": 921,
"middle_length": 229
} |
iates.
*
* 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 {ViewTransitionClass, ViewTransitionProps} from 'shared/ReactTypes';
import type {FiberRoot} from './ReactInternalTypes';
import type {ViewTransitionInstan... | nstance>, // a temporary state during the apply gesture phase if we cloned this boundary
ref: null | ViewTransitionInstance, // the current ref instance. This can change through the lifetime of the instance.
};
let globalClientIdCounter: number = 0;
ex | ng, // the view-transition-name to use when an explicit one is not specified
paired: null | ViewTransitionState, // a temporary state during the commit phase if we have paired this with another instance
clones: null | Array<I | {
"filepath": "packages/react-reconciler/src/ReactFiberViewTransitionComponent.js",
"language": "javascript",
"file_size": 2977,
"cut_index": 563,
"middle_length": 229
} |
* 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 {REACT_PORTAL_TYPE, REACT_OPTIMISTIC_KEY} from 'shared/ReactSymbols';
import {checkKeyStringCoercion} from 'shar... | se if (key === REACT_OPTIMISTIC_KEY) {
resolvedKey = REACT_OPTIMISTIC_KEY;
} else {
if (__DEV__) {
checkKeyStringCoercion(key);
}
resolvedKey = '' + key;
}
return {
// This tag allow us to uniquely identify this as a React P | nfo: any,
// TODO: figure out the API for cross-renderer implementation.
implementation: any,
key: ?string | ReactOptimisticKey = null,
): ReactPortal {
let resolvedKey;
if (key == null) {
resolvedKey = null;
} el | {
"filepath": "packages/react-reconciler/src/ReactPortal.js",
"language": "javascript",
"file_size": 1121,
"cut_index": 515,
"middle_length": 229
} |
ctLegacyMode} from './ReactTypeOfMode';
type FiberArray = Array<Fiber>;
type FiberToFiberComponentsMap = Map<Fiber, FiberArray>;
const ReactStrictModeWarnings = {
recordUnsafeLifecycleWarnings: (fiber: Fiber, instance: any): void => {},
flushPendingUnsafeLifecycleWarnings: (): void => {},
recordLegacyContextWar... | }
return maybeStrictRoot;
};
const setToSortedString = (set: Set<string>) => {
const array = [];
set.forEach(value => {
array.push(value);
});
return array.sort().join(', ');
};
let pendingComponentWillMountWarnings: | r): Fiber | null => {
let maybeStrictRoot = null;
let node: null | Fiber = fiber;
while (node !== null) {
if (node.mode & StrictLegacyMode) {
maybeStrictRoot = node;
}
node = node.return;
| {
"filepath": "packages/react-reconciler/src/ReactStrictModeWarnings.js",
"language": "javascript",
"file_size": 13858,
"cut_index": 921,
"middle_length": 229
} |
reconciler/src/ReactWorkTags';
import getComponentNameFromType from 'shared/getComponentNameFromType';
import {
findFiberRoot,
getBoundingRect,
getInstanceFromNode,
getTextContent,
isHiddenSubtree,
matchAccessibilityRole,
setFocusIfFocusable,
setupIntersectionObserver,
supportsTestSelectors,
} from '.... | or.has_pseudo_class');
ROLE_TYPE = symbolFor('selector.role');
TEST_NAME_TYPE = symbolFor('selector.test_id');
TEXT_TYPE = symbolFor('selector.text');
}
type Type = symbol | number;
type ComponentSelector = {
$$typeof: Type,
value: component(), | r = 0b011;
let TEXT_TYPE: symbol | number = 0b100;
if (typeof Symbol === 'function' && Symbol.for) {
const symbolFor = Symbol.for;
COMPONENT_TYPE = symbolFor('selector.component');
HAS_PSEUDO_CLASS_TYPE = symbolFor('select | {
"filepath": "packages/react-reconciler/src/ReactTestSelectors.js",
"language": "javascript",
"file_size": 15841,
"cut_index": 921,
"middle_length": 229
} |
import type {ReactContext, ReactConsumerType} from 'shared/ReactTypes';
import type {Fiber} from './ReactInternalTypes';
import {
disableLegacyMode,
enableLegacyHidden,
enableViewTransition,
} from 'shared/ReactFeatureFlags';
import {
FunctionComponent,
ClassComponent,
HostRoot,
HostPortal,
HostCompon... | onent,
Throw,
ViewTransitionComponent,
ActivityComponent,
} from 'react-reconciler/src/ReactWorkTags';
import getComponentNameFromType from 'shared/getComponentNameFromType';
import {REACT_STRICT_MODE_TYPE} from 'shared/ReactSymbols';
import type {Re | nt,
LazyComponent,
IncompleteClassComponent,
IncompleteFunctionComponent,
DehydratedFragment,
SuspenseListComponent,
ScopeComponent,
OffscreenComponent,
LegacyHiddenComponent,
CacheComponent,
TracingMarkerComp | {
"filepath": "packages/react-reconciler/src/getComponentNameFromFiber.js",
"language": "javascript",
"file_size": 5143,
"cut_index": 716,
"middle_length": 229
} |
et Activity;
let useState;
let assertLog;
describe('Activity error handling', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
Activity = React.Act... | ull};
static getDerivedStateFromError(error) {
return {error};
}
render() {
if (this.state.error) {
return (
<Text text={`Caught an error: ${this.state.error.message}`} />
); | .log(text);
return text;
}
it(
'errors inside a hidden Activity do not escape in the visible part ' +
'of the UI',
async () => {
class ErrorBoundary extends React.Component {
state = {error: n | {
"filepath": "packages/react-reconciler/src/__tests__/ActivityErrorHandling-test.js",
"language": "javascript",
"file_size": 2506,
"cut_index": 563,
"middle_length": 229
} |
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.
*
* @emails react-core
* @jest-environment node
*/
'use strict';
let act;
let Activity;
let React;
let ReactServer;
let ReactNoop;
let ReactNoopFlightCl... | oopFlightClient = require('react-noop-renderer/flight-client');
ReactNoop = require('react-noop-renderer');
const InternalTestUtils = require('internal-test-utils');
act = InternalTestUtils.act;
});
afterEach(() => {
jest.restoreAllMoc | eactServer = require('react');
Activity = ReactServer.Activity;
ReactNoopFlightServer = require('react-noop-renderer/flight-server');
jest.resetModules();
__unmockReact();
React = require('react');
ReactN | {
"filepath": "packages/react-reconciler/src/__tests__/ActivityReactServer-test.js",
"language": "javascript",
"file_size": 1615,
"cut_index": 537,
"middle_length": 229
} |
duler');
act = require('internal-test-utils').act;
LegacyHidden = React.unstable_LegacyHidden;
Activity = React.Activity;
Suspense = React.Suspense;
useState = React.useState;
useEffect = React.useEffect;
startTransition = React.startTransition;
use = React.use;
const InternalTestUt... | , newRecord);
} else if (record.status === 'pending') {
const resolve = record.resolve;
record.status = 'resolved';
record.value = text;
resolve();
}
}
function readText(text) {
const record = textCache.get(text);
| new Map();
});
function resolveText(text) {
const record = textCache.get(text);
if (record === undefined) {
const newRecord = {
status: 'resolved',
value: text,
};
textCache.set(text | {
"filepath": "packages/react-reconciler/src/__tests__/ActivitySuspense-test.js",
"language": "javascript",
"file_size": 15964,
"cut_index": 921,
"middle_length": 229
} |
;
// These tests are mostly concerned with concurrent roots. The legacy root
// behavior is covered by other older test suites and is unchanged from
// React 17.
describe('act warnings', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
Scheduler = require('scheduler');
ReactN... | nternalTestUtils.assertConsoleErrorDev;
});
function createTextCache() {
const data = new Map();
const version = caches.length + 1;
const cache = {
version,
data,
resolve(text) {
const record = data.get(text);
| t.unstable_getCacheForType;
caches = [];
const InternalTestUtils = require('internal-test-utils');
waitForAll = InternalTestUtils.waitForAll;
assertLog = InternalTestUtils.assertLog;
assertConsoleErrorDev = I | {
"filepath": "packages/react-reconciler/src/__tests__/ReactActWarnings-test.js",
"language": "javascript",
"file_size": 13555,
"cut_index": 921,
"middle_length": 229
} |
let TextResource;
let act;
describe('ReactBlockingMode', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
ReactCache = require('react-cache');
Suspense = React.Suspense;
const InternalT... | }, ms),
);
},
([text, ms]) => text,
);
});
function Text(props) {
Scheduler.log(props.text);
return props.text;
}
function AsyncText(props) {
const text = props.text;
try {
TextResource.read([props. | tCache.unstable_createResource(
([text, ms = 0]) => {
return new Promise((resolve, reject) =>
setTimeout(() => {
Scheduler.log(`Promise resolved [${text}]`);
resolve(text);
| {
"filepath": "packages/react-reconciler/src/__tests__/ReactBatching-test.internal.js",
"language": "javascript",
"file_size": 4387,
"cut_index": 614,
"middle_length": 229
} |
;
let waitForPaint;
describe('ReactSuspenseWithNoopRenderer', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
Suspense = React.Suspense;
useSt... | ejected':
throw Error('Failed to load: ' + text);
case 'resolved':
return text;
}
} else {
let ping;
const promise = new Promise(resolve => (ping = resolve));
const newRecord = {
| che = new Map();
readText = text => {
const record = textCache.get(text);
if (record !== undefined) {
switch (record.status) {
case 'pending':
throw record.promise;
case 'r | {
"filepath": "packages/react-reconciler/src/__tests__/ReactCPUSuspense-test.js",
"language": "javascript",
"file_size": 6796,
"cut_index": 716,
"middle_length": 229
} |
act;
let ReactNoop;
let Scheduler;
let act;
let assertLog;
describe('ReactClassSetStateCallback', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
... | ext text={this.state.step} />;
}
}
const root = ReactNoop.createRoot();
await act(() => {
root.render(<App />);
});
assertLog([0]);
await act(() => {
React.startTransition(() => {
app.setState({step: 1}, | gression: setState callback (2nd arg) should only fire once, even after a rebase', async () => {
let app;
class App extends React.Component {
state = {step: 0};
render() {
app = this;
return <T | {
"filepath": "packages/react-reconciler/src/__tests__/ReactClassSetStateCallback-test.js",
"language": "javascript",
"file_size": 1230,
"cut_index": 518,
"middle_length": 229
} |
ct-core
*/
'use strict';
let React;
let ReactDOMClient;
let Scheduler;
let container;
let act;
async function fakeAct(cb) {
// We don't use act/waitForThrow here because we want to observe how errors are reported for real.
await cb();
Scheduler.unstable_flushAll();
}
describe('ReactConfigurableErrorLogging',... | ctor(props) {
super(props);
throw new Error('constructor error');
}
render() {
return <div />;
}
}
const uncaughtErrors = [];
const caughtErrors = [];
const root = ReactDOMClient.createRoot(containe | ument.createElement('div');
if (__DEV__) {
act = React.act;
}
});
it('should log errors that occur during the begin phase', async () => {
class ErrorThrowingComponent extends React.Component {
constru | {
"filepath": "packages/react-reconciler/src/__tests__/ReactConfigurableErrorLogging-test.js",
"language": "javascript",
"file_size": 5900,
"cut_index": 716,
"middle_length": 229
} |
iates.
*
* 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 {FiberRoot} from './ReactInternalTypes';
import type {TransitionTypes} from 'react/src/ReactTransitionType';
import {enableViewTransition} from 'shared/Re... | nLane(root.pendingLanes)) {
let queued = root.transitionTypes;
if (queued === null) {
queued = root.transitionTypes = [];
}
for (let i = 0; i < transitionTypes.length; i++) {
const transitionType = transitionTypes[i] | iewTransition) {
// TODO: We should really store transitionTypes per lane in a LaneMap on
// the root. Then merge it when we commit. We currently assume that all
// Transitions are entangled.
if (includesTransitio | {
"filepath": "packages/react-reconciler/src/ReactFiberTransitionTypes.js",
"language": "javascript",
"file_size": 2086,
"cut_index": 563,
"middle_length": 229
} |
t type {TransitionTypes} from 'react/src/ReactTransitionType';
import type {WorkTag} from './ReactWorkTags';
import type {TypeOfMode} from './ReactTypeOfMode';
import type {Flags} from './ReactFiberFlags';
import type {Lane, Lanes, LaneMap} from './ReactFiberLane';
import type {RootTag} from './ReactRootTags';
import t... | rt type {ComponentStackNode} from 'react-server/src/ReactFizzComponentStack';
import type {ThenableState} from './ReactFiberThenable';
import type {ScheduledGesture} from './ReactFiberGestureScheduler';
// Unwind Circular: moved from ReactFiberHooks.old
e | eComponent';
import type {Transition} from 'react/src/ReactStartTransition';
import type {TracingMarkerInstance} from './ReactFiberTracingMarkerComponent';
import type {ConcurrentUpdate} from './ReactFiberConcurrentUpdates';
impo | {
"filepath": "packages/react-reconciler/src/ReactInternalTypes.js",
"language": "javascript",
"file_size": 15088,
"cut_index": 921,
"middle_length": 229
} |
, 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
*/
export type TypeOfMode = number;
export const NoMode = /* */ 0b0000000;
// TODO: Remove ConcurrentMode by reading from the roo... | = /* */ 0b0001000;
export const StrictEffectsMode = /* */ 0b0010000;
// Keep track of if we're in a SuspenseyImages eligible subtree.
// TODO: Remove this when enableSuspenseyImages ship where it's always on.
export const Suspens | 0b0000100; // Removed
export const StrictLegacyMode | {
"filepath": "packages/react-reconciler/src/ReactTypeOfMode.js",
"language": "javascript",
"file_size": 898,
"cut_index": 547,
"middle_length": 52
} |
onst root = ReactNoop.createRoot();
await act(async () => {
root.render(<App mode="unstable-defer-without-hiding" />);
await waitForPaint(['Normal']);
expect(root).toMatchRenderedOutput(<span prop="Normal" />);
});
assertLog(['Deferred']);
expect(root).toMatchRenderedOutput(
<>
... | e-defer-without-hiding" />);
await waitForPaint(['Normal']);
expect(root).toMatchRenderedOutput(
<>
<span prop="Normal" />
<span prop="Deferred" />
</>,
);
});
assertLog(['Deferred']);
expec | sertLog(['Normal', 'Deferred']);
expect(root).toMatchRenderedOutput(
<>
<span prop="Normal" />
<span prop="Deferred" />
</>,
);
await act(async () => {
root.render(<App mode="unstabl | {
"filepath": "packages/react-reconciler/src/__tests__/Activity-test.js",
"language": "javascript",
"file_size": 45134,
"cut_index": 2151,
"middle_length": 229
} |
React.Activity;
ReactNoop = require('react-noop-renderer');
act = require('internal-test-utils').act;
});
function Component({label}) {
React.useEffect(() => {
log.push(`${label}: useEffect mount`);
return () => log.push(`${label}: useEffect unmount`);
});
React.useLayoutEffect(()... | <Component label="A" />
</Activity>
</React.StrictMode>,
);
});
expect(log).toEqual([
'A: render',
'A: render',
'A: useLayoutEffect mount',
'A: useEffect mount',
'A: useLayoutEffect unmount',
| pan>;
}
// @gate __DEV__
it('should trigger strict effects when offscreen is visible', async () => {
await act(() => {
ReactNoop.render(
<React.StrictMode>
<Activity mode="visible">
| {
"filepath": "packages/react-reconciler/src/__tests__/ActivityStrictMode-test.js",
"language": "javascript",
"file_size": 8202,
"cut_index": 716,
"middle_length": 229
} |
henable = {
pings: [],
then(resolve) {
if (newRecord.status === 'pending') {
thenable.pings.push(resolve);
} else {
Promise.resolve().then(() => resolve(newRecord.value));
}
},
};
const newRecord = {
status: 'pending',
... | resolve(newRecord.value));
}
},
};
const newRecord = {
status: 'pending',
value: thenable,
};
textCache.set(text, newRecord);
return thenable;
} else {
switch (record.status) {
| defined) {
const thenable = {
pings: [],
then(resolve) {
if (newRecord.status === 'pending') {
thenable.pings.push(resolve);
} else {
Promise.resolve().then(() => | {
"filepath": "packages/react-reconciler/src/__tests__/ReactAsyncActions-test.js",
"language": "javascript",
"file_size": 52907,
"cut_index": 2151,
"middle_length": 229
} |
ct-core
* @jest-environment node
*/
'use strict';
let React;
let ReactNoopFlightServer;
let ReactNoopFlightClient;
let cache;
let cacheSignal;
describe('ReactCache', () => {
beforeEach(() => {
jest.resetModules();
jest.mock('react', () => require('react/react.react-server'));
React = require('react')... | on Print({a, b}) {
return types(a, b).a + ' ' + types(a, b).b + ' ';
}
function Same({a, b}) {
const x = types(a, b);
const y = types(a, b);
return (x === y).toString() + ' ';
}
function FlippedOrder({a, b}) {
| = React.cacheSignal;
jest.resetModules();
__unmockReact();
});
it('cache objects and primitive arguments and a mix of them', async () => {
const types = cache((a, b) => ({a: typeof a, b: typeof b}));
functi | {
"filepath": "packages/react-reconciler/src/__tests__/ReactCache-test.js",
"language": "javascript",
"file_size": 8401,
"cut_index": 716,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.