Commit 8bda715
authored
[Fiber] support hydration when rendering Suspense anywhere (#32224)
follow up to #32163
This continues the work of making Suspense workable anywhere in a
react-dom tree. See the prior PRs for how we handle server rendering and
client rendering. In this change we update the hydration implementation
to be able to locate expected nodes. In particular this means hydration
understands now that the default hydration context is the document body
when the container is above the body.
One case that is unique to hydration is clearing Suspense boundaries.
When hydration fails or when the server instructs the client to recover
an errored boundary it's possible that the html, head, and body tags in
the initial document were written from a fallback or a different primary
content on the server and need to be replaced by the client render.
However these tags (and in the case of head, their content) won't be
inside the comment nodes that identify the bounds of the Suspense
boundary. And when client rendering you may not even render the same
singletons that were server rendered. So when server rendering a
boudnary which contributes to the preamble (the html, head, and body tag
openings plus the head contents) we emit a special marker comment just
before closing the boundary out. This marker encodes which parts of the
preamble this boundary owned. If we need to clear the suspense boundary
on the client we read this marker and use it to reset the appropriate
singleton state.1 parent f82c662 commit 8bda715
File tree
11 files changed
+833
-40
lines changed- packages
- react-dom-bindings/src
- client
- server
- react-dom/src/__tests__
- react-markup/src
- react-reconciler/src
- forks
- react-server/src
11 files changed
+833
-40
lines changedLines changed: 108 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
210 | 213 | | |
211 | 214 | | |
212 | 215 | | |
| |||
963 | 966 | | |
964 | 967 | | |
965 | 968 | | |
| 969 | + | |
966 | 970 | | |
967 | 971 | | |
968 | 972 | | |
| |||
973 | 977 | | |
974 | 978 | | |
975 | 979 | | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
976 | 1010 | | |
977 | 1011 | | |
978 | 1012 | | |
| |||
987 | 1021 | | |
988 | 1022 | | |
989 | 1023 | | |
| 1024 | + | |
| 1025 | + | |
990 | 1026 | | |
| 1027 | + | |
| 1028 | + | |
991 | 1029 | | |
992 | 1030 | | |
993 | 1031 | | |
| |||
1501 | 1539 | | |
1502 | 1540 | | |
1503 | 1541 | | |
1504 | | - | |
| 1542 | + | |
1505 | 1543 | | |
1506 | 1544 | | |
1507 | 1545 | | |
| |||
1513 | 1551 | | |
1514 | 1552 | | |
1515 | 1553 | | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
1516 | 1575 | | |
1517 | 1576 | | |
1518 | 1577 | | |
| |||
1874 | 1933 | | |
1875 | 1934 | | |
1876 | 1935 | | |
1877 | | - | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
1878 | 1950 | | |
1879 | 1951 | | |
1880 | 1952 | | |
| |||
1883 | 1955 | | |
1884 | 1956 | | |
1885 | 1957 | | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
1886 | 1992 | | |
1887 | 1993 | | |
1888 | 1994 | | |
| |||
Lines changed: 78 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
684 | 684 | | |
685 | 685 | | |
686 | 686 | | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
687 | 692 | | |
688 | 693 | | |
689 | 694 | | |
690 | 695 | | |
| 696 | + | |
691 | 697 | | |
692 | 698 | | |
693 | 699 | | |
694 | 700 | | |
695 | 701 | | |
696 | 702 | | |
| 703 | + | |
697 | 704 | | |
698 | 705 | | |
699 | 706 | | |
| |||
3227 | 3234 | | |
3228 | 3235 | | |
3229 | 3236 | | |
3230 | | - | |
| 3237 | + | |
3231 | 3238 | | |
3232 | 3239 | | |
3233 | 3240 | | |
| |||
3251 | 3258 | | |
3252 | 3259 | | |
3253 | 3260 | | |
3254 | | - | |
| 3261 | + | |
3255 | 3262 | | |
3256 | 3263 | | |
3257 | 3264 | | |
| |||
3275 | 3282 | | |
3276 | 3283 | | |
3277 | 3284 | | |
3278 | | - | |
| 3285 | + | |
3279 | 3286 | | |
3280 | 3287 | | |
3281 | 3288 | | |
| |||
3416 | 3423 | | |
3417 | 3424 | | |
3418 | 3425 | | |
| 3426 | + | |
| 3427 | + | |
| 3428 | + | |
| 3429 | + | |
| 3430 | + | |
| 3431 | + | |
| 3432 | + | |
| 3433 | + | |
| 3434 | + | |
| 3435 | + | |
| 3436 | + | |
| 3437 | + | |
| 3438 | + | |
| 3439 | + | |
| 3440 | + | |
| 3441 | + | |
| 3442 | + | |
| 3443 | + | |
| 3444 | + | |
| 3445 | + | |
| 3446 | + | |
| 3447 | + | |
| 3448 | + | |
| 3449 | + | |
| 3450 | + | |
| 3451 | + | |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
| 3458 | + | |
| 3459 | + | |
| 3460 | + | |
| 3461 | + | |
| 3462 | + | |
3419 | 3463 | | |
3420 | 3464 | | |
3421 | 3465 | | |
| |||
3907 | 3951 | | |
3908 | 3952 | | |
3909 | 3953 | | |
3910 | | - | |
| 3954 | + | |
3911 | 3955 | | |
| 3956 | + | |
3912 | 3957 | | |
3913 | | - | |
| 3958 | + | |
3914 | 3959 | | |
| 3960 | + | |
3915 | 3961 | | |
3916 | | - | |
| 3962 | + | |
3917 | 3963 | | |
| 3964 | + | |
3918 | 3965 | | |
3919 | 3966 | | |
3920 | 3967 | | |
| |||
4091 | 4138 | | |
4092 | 4139 | | |
4093 | 4140 | | |
| 4141 | + | |
4094 | 4142 | | |
| 4143 | + | |
| 4144 | + | |
| 4145 | + | |
4095 | 4146 | | |
4096 | 4147 | | |
4097 | 4148 | | |
| |||
4103 | 4154 | | |
4104 | 4155 | | |
4105 | 4156 | | |
| 4157 | + | |
4106 | 4158 | | |
| 4159 | + | |
| 4160 | + | |
| 4161 | + | |
4107 | 4162 | | |
4108 | 4163 | | |
4109 | 4164 | | |
| 4165 | + | |
| 4166 | + | |
| 4167 | + | |
| 4168 | + | |
| 4169 | + | |
| 4170 | + | |
| 4171 | + | |
| 4172 | + | |
| 4173 | + | |
| 4174 | + | |
| 4175 | + | |
| 4176 | + | |
| 4177 | + | |
| 4178 | + | |
| 4179 | + | |
| 4180 | + | |
| 4181 | + | |
4110 | 4182 | | |
4111 | 4183 | | |
4112 | 4184 | | |
| |||
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| 247 | + | |
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
250 | 251 | | |
251 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
252 | 257 | | |
253 | 258 | | |
254 | 259 | | |
255 | 260 | | |
| 261 | + | |
256 | 262 | | |
257 | 263 | | |
258 | 264 | | |
259 | 265 | | |
260 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
261 | 271 | | |
262 | 272 | | |
263 | 273 | | |
| |||
0 commit comments