MCPcopy
hub / github.com/facebook/react / requestUpdateLane

Function requestUpdateLane

packages/react-reconciler/src/ReactFiberWorkLoop.js:792–836  ·  view source on GitHub ↗
(fiber: Fiber)

Source from the content-addressed store, hash-verified

790}
791
792export function requestUpdateLane(fiber: Fiber): Lane {
793 // Special cases
794 const mode = fiber.mode;
795 if (!disableLegacyMode && (mode & ConcurrentMode) === NoMode) {
796 return (SyncLane: Lane);
797 } else if (
798 (executionContext & RenderContext) !== NoContext &&
799 workInProgressRootRenderLanes !== NoLanes
800 ) {
801 // This is a render phase update. These are not officially supported. The
802 // old behavior is to give this the same "thread" (lanes) as
803 // whatever is currently rendering. So if you call `setState` on a component
804 // that happens later in the same render, it will flush. Ideally, we want to
805 // remove the special case and treat them as if they came from an
806 // interleaved event. Regardless, this pattern is not officially supported.
807 // This behavior is only a fallback. The flag only exists until we can roll
808 // out the setState warning, since existing code might accidentally rely on
809 // the current behavior.
810 return pickArbitraryLane(workInProgressRootRenderLanes);
811 }
812
813 const transition = requestCurrentTransition();
814 if (transition !== null) {
815 if (enableGestureTransition) {
816 if (transition.gesture) {
817 throw new Error(
818 'Cannot setState on regular state inside a startGestureTransition. ' +
819 'Gestures can only update the useOptimistic() hook. There should be no ' +
820 'side-effects associated with starting a Gesture until its Action is ' +
821 'invoked. Move side-effects to the Action instead.',
822 );
823 }
824 }
825 if (__DEV__) {
826 if (!transition._updatedFibers) {
827 transition._updatedFibers = new Set();
828 }
829 transition._updatedFibers.add(fiber);
830 }
831
832 return requestTransitionLane(transition);
833 }
834
835 return eventPriorityToLane(resolveUpdatePriority());
836}
837
838function requestRetryLane(fiber: Fiber) {
839 // This is a fork of `requestUpdateLane` designed specifically for Suspense

Callers 8

ReactFiberHooks.jsFile · 0.90
switchFunction · 0.90
createHydrationContainerFunction · 0.90
updateContainerFunction · 0.90
enqueueSetStateFunction · 0.90
enqueueReplaceStateFunction · 0.90
enqueueForceUpdateFunction · 0.90

Calls 6

pickArbitraryLaneFunction · 0.90
requestCurrentTransitionFunction · 0.90
requestTransitionLaneFunction · 0.90
eventPriorityToLaneFunction · 0.90
resolveUpdatePriorityFunction · 0.90
addMethod · 0.80

Tested by

no test coverage detected