Skip to content

Commit 796db96

Browse files
committed
Replace pendingWorkPriority with expiration times
Instead of a priority, a fiber has an expiration time that represents a point in the future by which it should render. Pending updates still have priorities so that they can be coalesced. We use a host config method to read the current time. This commit implements everything except that method, which currently returns a constant value. So this just proves that expiration times work the same as priorities when time is frozen. Subsequent commits will show the effect of advancing time.
1 parent 7ef34ab commit 796db96

11 files changed

+567
-395
lines changed

src/renderers/dom/fiber/ReactDOMFiberEntry.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,20 @@ function shouldAutoFocusHostComponent(type: string, props: Props): boolean {
164164
}
165165

166166
// TODO: Better polyfill
167-
let now;
168-
if (
169-
typeof window !== 'undefined' &&
170-
window.performance &&
171-
typeof window.performance.now === 'function'
172-
) {
173-
now = function() {
174-
return performance.now();
175-
};
176-
} else {
177-
now = function() {
178-
return Date.now();
179-
};
180-
}
167+
// let now;
168+
// if (
169+
// typeof window !== 'undefined' &&
170+
// window.performance &&
171+
// typeof window.performance.now === 'function'
172+
// ) {
173+
// now = function() {
174+
// return performance.now();
175+
// };
176+
// } else {
177+
// now = function() {
178+
// return Date.now();
179+
// };
180+
// }
181181

182182
var DOMRenderer = ReactFiberReconciler({
183183
getRootHostContext(rootContainerInstance: Container): HostContext {
@@ -447,7 +447,10 @@ var DOMRenderer = ReactFiberReconciler({
447447
}
448448
},
449449

450-
now: now,
450+
now() {
451+
// TODO: Use performance.now to enable expiration
452+
return 0;
453+
},
451454

452455
canHydrateInstance(
453456
instance: Instance | TextInstance,

src/renderers/noop/ReactNoopEntry.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,15 @@ var ReactNoop = {
412412
' '.repeat(depth + 1) + '~',
413413
firstUpdate && firstUpdate.partialState,
414414
firstUpdate.callback ? 'with callback' : '',
415-
'[' + firstUpdate.priorityLevel + ']',
415+
'[' + firstUpdate.expirationTime + ']',
416416
);
417417
var next;
418418
while ((next = firstUpdate.next)) {
419419
log(
420420
' '.repeat(depth + 1) + '~',
421421
next.partialState,
422422
next.callback ? 'with callback' : '',
423-
'[' + firstUpdate.priorityLevel + ']',
423+
'[' + firstUpdate.expirationTime + ']',
424424
);
425425
}
426426
}
@@ -430,7 +430,7 @@ var ReactNoop = {
430430
' '.repeat(depth) +
431431
'- ' +
432432
(fiber.type ? fiber.type.name || fiber.type : '[root]'),
433-
'[' + fiber.pendingWorkPriority + (fiber.pendingProps ? '*' : '') + ']',
433+
'[' + fiber.expirationTime + (fiber.pendingProps ? '*' : '') + ']',
434434
);
435435
if (fiber.updateQueue) {
436436
logUpdateQueue(fiber.updateQueue, depth);

0 commit comments

Comments
 (0)