Commit 2e3e6a9
Unify ReactFiberCurrentOwner and ReactCurrentFiber (#29038)
We previously had two slightly different concepts for "current fiber".
There's the "owner" which is set inside of class components in prod if
string refs are enabled, and sometimes inside function components in DEV
but not other contexts.
Then we have the "current fiber" which is only set in DEV for various
warnings but is enabled in a bunch of contexts.
This unifies them into a single "current fiber".
The concept of string refs shouldn't really exist so this should really
be a DEV only concept. In the meantime, this sets the current fiber
inside class render only in prod, however, in DEV it's now enabled in
more contexts which can affect the string refs. That was already the
case that a string ref in a Function component was only connecting to
the owner in prod. Any string ref associated with any non-class won't
work regardless so that's not an issue. The practical change here is
that an element with a string ref created inside a life-cycle associated
with a class will work in DEV but not in prod. Since we need the current
fiber to be available in more contexts in DEV for the debugging
purposes. That wouldn't affect any old code since it would have a broken
ref anyway. New code shouldn't use string refs anyway.
The other implication is that "owner" doesn't necessarily mean
"rendering" since we need the "owner" to track other debug information
like stacks - in other contexts like useEffect, life cycles, etc.
Internally we have a separate `isRendering` flag that actually means
we're rendering but even that is a very overloaded concept. So anything
that uses "owner" to imply rendering might be wrong with this change.
This is a first step to a larger refactor for tracking current rendering
information.
---------
Co-authored-by: Sebastian Silbermann <[email protected]>1 parent 4c2e457 commit 2e3e6a9
File tree
13 files changed
+56
-66
lines changed- packages
- react-dom/src
- __tests__
- client
- react-native-renderer/src
- react-reconciler/src
13 files changed
+56
-66
lines changedLines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2586 | 2586 | | |
2587 | 2587 | | |
2588 | 2588 | | |
2589 | | - | |
| 2589 | + | |
2590 | 2590 | | |
2591 | 2591 | | |
2592 | 2592 | | |
2593 | 2593 | | |
2594 | 2594 | | |
2595 | 2595 | | |
2596 | | - | |
| 2596 | + | |
2597 | 2597 | | |
2598 | 2598 | | |
2599 | 2599 | | |
| |||
2648 | 2648 | | |
2649 | 2649 | | |
2650 | 2650 | | |
2651 | | - | |
| 2651 | + | |
2652 | 2652 | | |
2653 | 2653 | | |
2654 | 2654 | | |
2655 | 2655 | | |
2656 | 2656 | | |
2657 | 2657 | | |
2658 | | - | |
| 2658 | + | |
2659 | 2659 | | |
2660 | 2660 | | |
2661 | 2661 | | |
| |||
2705 | 2705 | | |
2706 | 2706 | | |
2707 | 2707 | | |
2708 | | - | |
| 2708 | + | |
2709 | 2709 | | |
2710 | 2710 | | |
2711 | 2711 | | |
2712 | 2712 | | |
2713 | 2713 | | |
2714 | 2714 | | |
2715 | 2715 | | |
2716 | | - | |
| 2716 | + | |
2717 | 2717 | | |
2718 | 2718 | | |
2719 | 2719 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
502 | | - | |
503 | | - | |
| 502 | + | |
| 503 | + | |
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| |||
343 | 346 | | |
344 | 347 | | |
345 | 348 | | |
346 | | - | |
| 349 | + | |
347 | 350 | | |
348 | 351 | | |
349 | 352 | | |
| |||
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
35 | | - | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
44 | 56 | | |
45 | 57 | | |
46 | 58 | | |
47 | | - | |
48 | 59 | | |
49 | 60 | | |
| 61 | + | |
50 | 62 | | |
51 | 63 | | |
52 | 64 | | |
53 | 65 | | |
54 | 66 | | |
55 | 67 | | |
56 | | - | |
57 | 68 | | |
58 | 69 | | |
| 70 | + | |
59 | 71 | | |
60 | 72 | | |
61 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| |||
296 | 297 | | |
297 | 298 | | |
298 | 299 | | |
299 | | - | |
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
435 | | - | |
436 | 435 | | |
437 | 436 | | |
438 | 437 | | |
| |||
1150 | 1149 | | |
1151 | 1150 | | |
1152 | 1151 | | |
1153 | | - | |
1154 | 1152 | | |
1155 | 1153 | | |
1156 | 1154 | | |
| |||
1373 | 1371 | | |
1374 | 1372 | | |
1375 | 1373 | | |
1376 | | - | |
| 1374 | + | |
1377 | 1375 | | |
1378 | 1376 | | |
1379 | 1377 | | |
| |||
3419 | 3417 | | |
3420 | 3418 | | |
3421 | 3419 | | |
3422 | | - | |
3423 | 3420 | | |
3424 | 3421 | | |
3425 | 3422 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
| 104 | + | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
2486 | 2486 | | |
2487 | 2487 | | |
2488 | 2488 | | |
2489 | | - | |
| 2489 | + | |
2490 | 2490 | | |
2491 | 2491 | | |
2492 | 2492 | | |
| |||
3125 | 3125 | | |
3126 | 3126 | | |
3127 | 3127 | | |
| 3128 | + | |
3128 | 3129 | | |
3129 | 3130 | | |
| 3131 | + | |
3130 | 3132 | | |
3131 | 3133 | | |
3132 | 3134 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
| 81 | + | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
0 commit comments