GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Apply #20778 to new fork, too (#20782) · react/react@3499c34

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • react-dom/src/__tests__
      • ReactDOMServerSelectiveHydration-test.internal.js
    • react-noop-renderer/src
      • ReactNoop.js
      • ReactNoopPersistent.js
      • createReactNoop.js
    • react-reconciler/src
      • ReactFiberLane.new.js
      • ReactFiberLane.old.js
      • ReactFiberReconciler.js
      • ReactFiberReconciler.new.js
      • ReactFiberReconciler.old.js
      • ReactFiberWorkLoop.new.js
      • __tests__
        • ReactExpiration-test.js
        • ReactHooksWithNoopRenderer-test.js
        • ReactSchedulerIntegration-test.js
        • ReactSuspenseWithNoopRenderer-test.js
        • useMutableSource-test.internal.js
        • useMutableSourceHydration-test.js
    • react/src/__tests__
      • ReactDOMTracing-test.internal.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js‎

Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js
+19-6Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ function dispatchClickEvent(target) {
9292
return target.dispatchEvent(mouseOutEvent);
9393
}
9494

95+
// TODO: There's currently no React DOM API to opt into Idle priority updates,
96+
// and there's no native DOM event that maps to idle priority, so this is a
97+
// temporary workaround. Need something like ReactDOM.unstable_IdleUpdates.
98+
function TODO_scheduleIdleDOMSchedulerTask(fn) {
99+
Scheduler.unstable_runWithPriority(Scheduler.unstable_IdlePriority, () => {
100+
const prevEvent = window.event;
101+
window.event = {type: 'message'};
102+
try {
103+
fn();
104+
} finally {
105+
window.event = prevEvent;
106+
}
107+
});
108+
}
109+
95110
describe('ReactDOMServerSelectiveHydration', () => {
96111
beforeEach(() => {
97112
jest.resetModuleRegistry();
@@ -889,12 +904,10 @@ describe('ReactDOMServerSelectiveHydration', () => {
889904
expect(Scheduler).toFlushAndYieldThrough(['App', 'Commit']);
890905

891906
// Render an update at Idle priority that needs to update A.
892-
Scheduler.unstable_runWithPriority(
893-
Scheduler.unstable_IdlePriority,
894-
() => {
895-
root.render(<App a="AA" />);
896-
},
897-
);
907+
908+
TODO_scheduleIdleDOMSchedulerTask(() => {
909+
root.render(<App a="AA" />);
910+
});
898911

899912
// Start rendering. This will force the first boundary to hydrate
900913
// by scheduling it at one higher pri than Idle.
Collapse file

‎packages/react-noop-renderer/src/ReactNoop.js‎

Copy file name to clipboardExpand all lines: packages/react-noop-renderer/src/ReactNoop.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const {
4141
deferredUpdates,
4242
unbatchedUpdates,
4343
discreteUpdates,
44+
idleUpdates,
4445
flushDiscreteUpdates,
4546
flushSync,
4647
flushPassiveEffects,
Collapse file

‎packages/react-noop-renderer/src/ReactNoopPersistent.js‎

Copy file name to clipboardExpand all lines: packages/react-noop-renderer/src/ReactNoopPersistent.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const {
4141
deferredUpdates,
4242
unbatchedUpdates,
4343
discreteUpdates,
44+
idleUpdates,
4445
flushDiscreteUpdates,
4546
flushSync,
4647
flushPassiveEffects,
Collapse file

‎packages/react-noop-renderer/src/createReactNoop.js‎

Copy file name to clipboardExpand all lines: packages/react-noop-renderer/src/createReactNoop.js
+21-1Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
LegacyRoot,
2828
} from 'react-reconciler/src/ReactRootTags';
2929

30+
import {enableNativeEventPriorityInference} from 'shared/ReactFeatureFlags';
3031
import ReactSharedInternals from 'shared/ReactSharedInternals';
3132
import enqueueTask from 'shared/enqueueTask';
3233
const {IsSomeRendererActing} = ReactSharedInternals;
@@ -392,7 +393,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
392393
resetAfterCommit(): void {},
393394

394395
getCurrentEventPriority() {
395-
return NoopRenderer.DefaultEventPriority;
396+
return currentEventPriority;
396397
},
397398

398399
now: Scheduler.unstable_now,
@@ -587,6 +588,8 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
587588
const roots = new Map();
588589
const DEFAULT_ROOT_ID = '<default>';
589590

591+
let currentEventPriority = NoopRenderer.DefaultEventPriority;
592+
590593
function childToJSX(child, text) {
591594
if (text !== null) {
592595
return text;
@@ -925,6 +928,23 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
925928

926929
discreteUpdates: NoopRenderer.discreteUpdates,
927930

931+
idleUpdates<T>(fn: () => T): T {
932+
if (enableNativeEventPriorityInference) {
933+
const prevEventPriority = currentEventPriority;
934+
currentEventPriority = NoopRenderer.IdleEventPriority;
935+
try {
936+
fn();
937+
} finally {
938+
currentEventPriority = prevEventPriority;
939+
}
940+
} else {
941+
return Scheduler.unstable_runWithPriority(
942+
Scheduler.unstable_IdlePriority,
943+
fn,
944+
);
945+
}
946+
},
947+
928948
flushDiscreteUpdates: NoopRenderer.flushDiscreteUpdates,
929949

930950
flushSync(fn: () => mixed) {
Collapse file

‎packages/react-reconciler/src/ReactFiberLane.new.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberLane.new.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const RetryLanePriority: LanePriority = 5;
7070
const SelectiveHydrationLanePriority: LanePriority = 4;
7171

7272
const IdleHydrationLanePriority: LanePriority = 3;
73-
const IdleLanePriority: LanePriority = 2;
73+
export const IdleLanePriority: LanePriority = 2;
7474

7575
const OffscreenLanePriority: LanePriority = 1;
7676

@@ -275,6 +275,7 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
275275

276276
// Check if any work has expired.
277277
if (expiredLanes !== NoLanes) {
278+
// TODO: Should entangle with SyncLane
278279
nextLanes = expiredLanes;
279280
nextLanePriority = return_highestLanePriority = SyncLanePriority;
280281
} else {
Collapse file

‎packages/react-reconciler/src/ReactFiberLane.old.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberLane.old.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const RetryLanePriority: LanePriority = 5;
7070
const SelectiveHydrationLanePriority: LanePriority = 4;
7171

7272
const IdleHydrationLanePriority: LanePriority = 3;
73-
const IdleLanePriority: LanePriority = 2;
73+
export const IdleLanePriority: LanePriority = 2;
7474

7575
const OffscreenLanePriority: LanePriority = 1;
7676

@@ -275,6 +275,7 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
275275

276276
// Check if any work has expired.
277277
if (expiredLanes !== NoLanes) {
278+
// TODO: Should entangle with SyncLane
278279
nextLanes = expiredLanes;
279280
nextLanePriority = return_highestLanePriority = SyncLanePriority;
280281
} else {
Collapse file

‎packages/react-reconciler/src/ReactFiberReconciler.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberReconciler.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import {
5555
DefaultEventPriority as DefaultEventPriority_old,
5656
DiscreteEventPriority as DiscreteEventPriority_old,
5757
ContinuousEventPriority as ContinuousEventPriority_old,
58+
IdleEventPriority as IdleEventPriority_old,
5859
} from './ReactFiberReconciler.old';
5960

6061
import {
@@ -98,6 +99,7 @@ import {
9899
DefaultEventPriority as DefaultEventPriority_new,
99100
DiscreteEventPriority as DiscreteEventPriority_new,
100101
ContinuousEventPriority as ContinuousEventPriority_new,
102+
IdleEventPriority as IdleEventPriority_new,
101103
} from './ReactFiberReconciler.new';
102104

103105
export const createContainer = enableNewReconciler
@@ -183,6 +185,9 @@ export const DiscreteEventPriority = enableNewReconciler
183185
export const ContinuousEventPriority = enableNewReconciler
184186
? ContinuousEventPriority_new
185187
: ContinuousEventPriority_old;
188+
export const IdleEventPriority = enableNewReconciler
189+
? IdleEventPriority_new
190+
: IdleEventPriority_old;
186191

187192
//TODO: "psuedo" is spelled "pseudo"
188193
export const createHasPsuedoClassSelector = enableNewReconciler
Collapse file

‎packages/react-reconciler/src/ReactFiberReconciler.new.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberReconciler.new.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export {
101101
InputDiscreteLanePriority as DiscreteEventPriority,
102102
InputContinuousLanePriority as ContinuousEventPriority,
103103
DefaultLanePriority as DefaultEventPriority,
104+
IdleLanePriority as IdleEventPriority,
104105
} from './ReactFiberLane.new';
105106

106107
export {registerMutableSourceForHydration} from './ReactMutableSource.new';
Collapse file

‎packages/react-reconciler/src/ReactFiberReconciler.old.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberReconciler.old.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export {
101101
InputDiscreteLanePriority as DiscreteEventPriority,
102102
InputContinuousLanePriority as ContinuousEventPriority,
103103
DefaultLanePriority as DefaultEventPriority,
104+
IdleLanePriority as IdleEventPriority,
104105
} from './ReactFiberLane.old';
105106

106107
export {registerMutableSourceForHydration} from './ReactMutableSource.new';
Collapse file

‎packages/react-reconciler/src/ReactFiberWorkLoop.new.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+1-9Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,7 @@ export function requestUpdateLane(fiber: Fiber): Lane {
465465
} else {
466466
if (enableNativeEventPriorityInference) {
467467
const eventLanePriority = getCurrentEventPriority();
468-
if (eventLanePriority === DefaultLanePriority) {
469-
// TODO: move this case into the ReactDOM host config.
470-
const schedulerLanePriority = schedulerPriorityToLanePriority(
471-
schedulerPriority,
472-
);
473-
lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes);
474-
} else {
475-
lane = findUpdateLane(eventLanePriority, currentEventWipLanes);
476-
}
468+
lane = findUpdateLane(eventLanePriority, currentEventWipLanes);
477469
} else {
478470
const schedulerLanePriority = schedulerPriorityToLanePriority(
479471
schedulerPriority,

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.