25
import type {Lane} from './ReactFiberLane';
26
import type {SuspenseState} from './ReactFiberSuspenseComponent';
27
28
+import {LegacyRoot} from './ReactRootTags';
29
import {
30
findCurrentHostFiber,
31
findCurrentHostFiberWithNoPortals,
62
scheduleInitialHydrationOnRoot,
63
flushRoot,
64
batchedUpdates,
64
- flushSync,
65
+ flushSyncFromReconciler,
66
+ flushSyncWork,
67
isAlreadyRendering,
68
deferredUpdates,
69
discreteUpdates,
359
parentComponent: ?React$Component<any, any>,
360
callback: ?Function,
361
): Lane {
362
+ const current = container.current;
363
+ const lane = requestUpdateLane(current);
364
+ updateContainerImpl(
365
+ current,
366
+ lane,
367
+ element,
368
+ container,
369
+ parentComponent,
370
+ callback,
371
+ );
372
+ return lane;
373
+}
374
+
375
+export function updateContainerSync(
376
+ element: ReactNodeList,
377
+ container: OpaqueRoot,
378
+ parentComponent: ?React$Component<any, any>,
379
+ callback: ?Function,
380
+): Lane {
381
+ if (container.tag === LegacyRoot) {
382
+ flushPassiveEffects();
383
+ }
384
+ const current = container.current;
385
+ updateContainerImpl(
386
+ current,
387
+ SyncLane,
388
+ element,
389
+ container,
390
+ parentComponent,
391
+ callback,
392
+ );
393
+ return SyncLane;
394
+}
395
+
396
+function updateContainerImpl(
397
+ rootFiber: Fiber,
398
+ lane: Lane,
399
+ element: ReactNodeList,
400
+ container: OpaqueRoot,
401
+ parentComponent: ?React$Component<any, any>,
402
+ callback: ?Function,
403
+): void {
404
if (__DEV__) {
405
onScheduleRoot(container, element);
406
}
363
- const current = container.current;
364
- const lane = requestUpdateLane(current);
407
408
if (enableSchedulingProfiler) {
409
markRenderScheduled(lane);
452
update.callback = callback;
453
}
454
413
- const root = enqueueUpdate(current, update, lane);
455
+ const root = enqueueUpdate(rootFiber, update, lane);
456
if (root !== null) {
415
- scheduleUpdateOnFiber(root, current, lane);
416
- entangleTransitions(root, current, lane);
457
+ scheduleUpdateOnFiber(root, rootFiber, lane);
458
+ entangleTransitions(root, rootFiber, lane);
459
}
418
-
419
- return lane;
460
}
461
462
export {
463
batchedUpdates,
464
deferredUpdates,
465
discreteUpdates,
426
- flushSync,
466
+ flushSyncFromReconciler,
467
+ flushSyncWork,
468
isAlreadyRendering,
469
flushPassiveEffects,
470
};
497
break;
498
}
499
case SuspenseComponent: {
459
- flushSync(() => {
460
- const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
461
- if (root !== null) {
462
- scheduleUpdateOnFiber(root, fiber, SyncLane);
463
- }
464
- });
500
+ const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
501
+ if (root !== null) {
502
+ scheduleUpdateOnFiber(root, fiber, SyncLane);
503
+ }
504
+ flushSyncWork();
505
// If we're still blocked after this, we need to increase
506
// the priority of any promises resolving within this
507
// boundary so that they next attempt also has higher pri.