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

Function flushPassiveEffects

packages/react-reconciler/src/ReactFiberWorkLoop.js:4452–4487  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4450}
4451
4452function flushPassiveEffects(): boolean {
4453 if (pendingEffectsStatus !== PENDING_PASSIVE_PHASE) {
4454 return false;
4455 }
4456 // TODO: Merge flushPassiveEffectsImpl into this function. I believe they were only separate
4457 // in the first place because we used to wrap it with
4458 // `Scheduler.runWithPriority`, which accepts a function. But now we track the
4459 // priority within React itself, so we can mutate the variable directly.
4460 // Cache the root since pendingEffectsRoot is cleared in
4461 // flushPassiveEffectsImpl
4462 const root = pendingEffectsRoot;
4463 // Cache and clear the remaining lanes flag; it must be reset since this
4464 // method can be called from various places, not always from commitRoot
4465 // where the remaining lanes are known
4466 const remainingLanes = pendingEffectsRemainingLanes;
4467 pendingEffectsRemainingLanes = NoLanes;
4468
4469 const renderPriority = lanesToEventPriority(pendingEffectsLanes);
4470 const priority = lowerEventPriority(DefaultEventPriority, renderPriority);
4471 const prevTransition = ReactSharedInternals.T;
4472 const previousPriority = getCurrentUpdatePriority();
4473
4474 try {
4475 setCurrentUpdatePriority(priority);
4476 ReactSharedInternals.T = null;
4477 return flushPassiveEffectsImpl();
4478 } finally {
4479 setCurrentUpdatePriority(previousPriority);
4480 ReactSharedInternals.T = prevTransition;
4481
4482 // Once passive effects have run for the tree - giving components a
4483 // chance to retain cache instances they use - release the pooled
4484 // cache at the root (if there is one)
4485 releaseRootPooledCache(root, remainingLanes);
4486 }
4487}
4488
4489function flushPassiveEffectsImpl() {
4490 // Cache and clear the transitions flag

Callers 2

commitRootFunction · 0.85
flushPendingEffectsFunction · 0.85

Calls 6

lanesToEventPriorityFunction · 0.90
lowerEventPriorityFunction · 0.90
getCurrentUpdatePriorityFunction · 0.90
setCurrentUpdatePriorityFunction · 0.90
flushPassiveEffectsImplFunction · 0.85
releaseRootPooledCacheFunction · 0.85

Tested by

no test coverage detected