Skip to content

Commit e31e4bd

Browse files
committed
Using expirationTime and childExpirationTime
Related pr facebook/react#13139
1 parent 9b94390 commit e31e4bd

9 files changed

+352
-199
lines changed

demo/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,5 @@
1717
"webpack": "4.28.4",
1818
"webpack-cli": "3.2.1",
1919
"webpack-dev-server": "3.1.14"
20-
},
21-
"dependencies": {
22-
"react": "16.8.0-alpha.1",
23-
"react-dom": "16.8.0-alpha.1"
2420
}
2521
}

demo/yarn.lock

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,7 +2796,7 @@ js-tokens@^3.0.0:
27962796
version "3.0.2"
27972797
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
27982798

2799-
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
2799+
js-tokens@^4.0.0:
28002800
version "4.0.0"
28012801
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
28022802
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
@@ -2927,13 +2927,6 @@ loose-envify@^1.0.0:
29272927
dependencies:
29282928
js-tokens "^3.0.0"
29292929

2930-
loose-envify@^1.1.0, loose-envify@^1.3.1:
2931-
version "1.4.0"
2932-
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
2933-
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
2934-
dependencies:
2935-
js-tokens "^3.0.0 || ^4.0.0"
2936-
29372930
lower-case@^1.1.1:
29382931
version "1.1.4"
29392932
resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac"
@@ -3326,7 +3319,7 @@ number-is-nan@^1.0.0:
33263319
version "1.0.1"
33273320
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
33283321

3329-
object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
3322+
object-assign@^4.0.1, object-assign@^4.1.0:
33303323
version "4.1.1"
33313324
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
33323325

@@ -3635,14 +3628,6 @@ promise-inflight@^1.0.1:
36353628
resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
36363629
integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM=
36373630

3638-
prop-types@^15.6.2:
3639-
version "15.6.2"
3640-
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102"
3641-
integrity sha512-3pboPvLiWD7dkI3qf3KbUe6hKFKa52w+AE0VCqECtf+QHAKgOL37tTaNCnuX1nAAQ4ZhyP+kYVKf8rLmJ/feDQ==
3642-
dependencies:
3643-
loose-envify "^1.3.1"
3644-
object-assign "^4.1.1"
3645-
36463631
proxy-addr@~2.0.4:
36473632
version "2.0.4"
36483633
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.4.tgz#ecfc733bf22ff8c6f407fa275327b9ab67e48b93"
@@ -3759,26 +3744,6 @@ rc@^1.2.7:
37593744
minimist "^1.2.0"
37603745
strip-json-comments "~2.0.1"
37613746

3762-
react-dom@16.8.0-alpha.1:
3763-
version "16.8.0-alpha.1"
3764-
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.0-alpha.1.tgz#dab73b8354ba2e498e3127d18e29d4546cea889e"
3765-
integrity sha512-tZCUM8BpnwUHJmLnUWP9c3vVZxnCqYotj7s4tx7umojG6BKv745KIBtuPTzt0EI0q50GMLEpmT/CPQ8iA61TwQ==
3766-
dependencies:
3767-
loose-envify "^1.1.0"
3768-
object-assign "^4.1.1"
3769-
prop-types "^15.6.2"
3770-
scheduler "^0.13.0-alpha.1"
3771-
3772-
react@16.8.0-alpha.1:
3773-
version "16.8.0-alpha.1"
3774-
resolved "https://registry.yarnpkg.com/react/-/react-16.8.0-alpha.1.tgz#c2b32689f3b466d3ce85a634dd9035f789d2cd97"
3775-
integrity sha512-vLwwnhM2dXrCsiQmcSxF2UdZVV5xsiXjK5Yetmy8dVqngJhQ3aw3YJhZN/YmyonxwdimH40wVqFQfsl4gSu2RA==
3776-
dependencies:
3777-
loose-envify "^1.1.0"
3778-
object-assign "^4.1.1"
3779-
prop-types "^15.6.2"
3780-
scheduler "^0.13.0-alpha.1"
3781-
37823747
"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@~2.3.6:
37833748
version "2.3.6"
37843749
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
@@ -4017,14 +3982,6 @@ sax@^1.2.4:
40173982
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
40183983
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==
40193984

4020-
scheduler@^0.13.0-alpha.1:
4021-
version "0.13.0-alpha.1"
4022-
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.0-alpha.1.tgz#753977fb4fb35d8cdd559868a11e46b640955556"
4023-
integrity sha512-W0sH0848sVuPKg+I18vTYQyzVtA4X1lrVgSeXK6KnOPUltFdJcY5nkbTkjGUeS/E0x+eBsNYfSdhJtGjT95njw==
4024-
dependencies:
4025-
loose-envify "^1.1.0"
4026-
object-assign "^4.1.1"
4027-
40283985
schema-utils@^0.4.4:
40293986
version "0.4.7"
40303987
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187"

src/ChildFiber.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
createFiberFromElement,
44
createFiberFromText,
55
} from "./Fiber";
6-
import { NoEffect, Deletion, Placement } from "./TypeOfSideEffect";
6+
import { Deletion, Placement } from "./TypeOfSideEffect";
77
import { HostText } from "./TypeOfWork";
88
import { REACT_ELEMENT_TYPE } from "./createElement";
99

src/Component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class Component {
1515
scheduleWork(fiber, expirationTime);
1616
}
1717

18-
isReactComponent = {};
18+
isReactComponent() {}
1919
}
2020

2121
export const ReactInstanceMap = {

src/Fiber.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from "./TypeOfWork";
1010
import { REACT_ASYNC_MODE_TYPE, REACT_STRICT_MODE_TYPE } from "./createElement";
1111
import { AsyncMode, StrictMode } from "./TypeOfMode";
12+
import { NoWork } from "./FiberExpirationTime";
1213

1314
export class FiberNode {
1415
constructor(tag, pendingProps, key, mode) {
@@ -31,18 +32,28 @@ export class FiberNode {
3132
this.memoizedState = null;
3233

3334
this.mode = mode;
35+
3436
// Effects
3537
this.effectTag = NoEffect;
3638
this.nextEffect = null;
3739
this.firstEffect = null;
3840
this.lastEffect = null;
41+
42+
this.expirationTime = NoWork;
43+
this.childExpirationTime = NoWork;
44+
3945
this.alternate = null;
4046
}
4147
}
4248

4349
export function createWorkInProgress(current, pendingProps, expirationTime) {
4450
let workInProgress = current.alternate;
4551
if (workInProgress == null) {
52+
// We use a double buffering pooling technique because we know that we'll
53+
// only ever need at most two versions of a tree. We pool the "other" unused
54+
// node that we're free to reuse. This is lazily created to avoid allocating
55+
// extra objects for things that are never updated. It also allow us to
56+
// reclaim the extra memory if needed.
4657
workInProgress = new FiberNode(
4758
current.tag,
4859
pendingProps,
@@ -55,21 +66,34 @@ export function createWorkInProgress(current, pendingProps, expirationTime) {
5566
workInProgress.alternate = current;
5667
current.alternate = workInProgress;
5768
} else {
69+
workInProgress.pendingProps = pendingProps;
70+
71+
// We already have an alternate.
72+
// Reset the effect tag.
5873
workInProgress.effectTag = NoEffect;
5974

75+
// The effect list is no longer valid.
6076
workInProgress.nextEffect = null;
6177
workInProgress.firstEffect = null;
6278
workInProgress.lastEffect = null;
6379
}
6480

65-
workInProgress.expirationTime = expirationTime;
66-
workInProgress.pendingProps = pendingProps;
81+
// Don't touching the subtree's expiration time, which has not changed.
82+
workInProgress.childExpirationTime = current.childExpirationTime;
83+
if (pendingProps !== current.pendingProps) {
84+
// This fiber has new props.
85+
workInProgress.expirationTime = expirationTime;
86+
} else {
87+
// This fiber's props have not changed.
88+
workInProgress.expirationTime = current.expirationTime;
89+
}
6790

6891
workInProgress.child = current.child;
6992
workInProgress.memoizedProps = current.memoizedProps;
7093
workInProgress.memoizedState = current.memoizedState;
7194
workInProgress.updateQueue = current.updateQueue;
7295

96+
// These will be overridden during the parent's reconciliation
7397
workInProgress.sibling = current.sibling;
7498
workInProgress.index = current.index;
7599
workInProgress.ref = current.ref;

0 commit comments

Comments
 (0)