@samitouri / QOS-React-2 / commits / 430e712bbd

[Fizz] Restrict types of keyPath when it is known (#27418)

When we render an element, we provide the newly created keypath because that means we're never at the root.

Sebastian Markbåge committed Sep 25, 2023 at 12:26 UTC 430e712bbd2e33cceb302b6e25fd7d8148b62019
1 file changed +18 -18
packages/react-server/src/ReactFizzServer.js
+18 -18
@@ -789,7 +789,7 @@ function fatalError(request: Request, error: mixed): void {
789 function renderSuspenseBoundary(
790 request: Request,
791 someTask: Task,
792 - keyPath: Root | KeyNode,
792 + keyPath: KeyNode,
793 props: Object,
794 ): void {
795 if (someTask.replay !== null) {
@@ -960,7 +960,7 @@ function renderSuspenseBoundary(
960 function replaySuspenseBoundary(
961 request: Request,
962 task: ReplayTask,
963 - keyPath: Root | KeyNode,
963 + keyPath: KeyNode,
964 props: Object,
965 id: number,
966 childNodes: Array<ReplayNode>,
@@ -1064,7 +1064,7 @@ function replaySuspenseBoundary(
1064 function renderBackupSuspenseBoundary(
1065 request: Request,
1066 task: Task,
1067 - keyPath: Root | KeyNode,
1067 + keyPath: KeyNode,
1068 props: Object,
1069 ) {
1070 pushBuiltInComponentStackInDEV(task, 'Suspense');
@@ -1090,7 +1090,7 @@ function renderBackupSuspenseBoundary(
1090 function renderHostElement(
1091 request: Request,
1092 task: Task,
1093 - keyPath: Root | KeyNode,
1093 + keyPath: KeyNode,
1094 type: string,
1095 props: Object,
1096 ): void {
@@ -1156,7 +1156,7 @@ function shouldConstruct(Component: any) {
1156 function renderWithHooks<Props, SecondArg>(
1157 request: Request,
1158 task: Task,
1159 - keyPath: Root | KeyNode,
1159 + keyPath: KeyNode,
1160 prevThenableState: ThenableState | null,
1161 Component: (p: Props, arg: SecondArg) => any,
1162 props: Props,
@@ -1177,7 +1177,7 @@ function renderWithHooks<Props, SecondArg>(
1177 function finishClassComponent(
1178 request: Request,
1179 task: Task,
1180 - keyPath: Root | KeyNode,
1180 + keyPath: KeyNode,
1181 instance: any,
1182 Component: any,
1183 props: any,
@@ -1223,7 +1223,7 @@ function finishClassComponent(
1223 function renderClassComponent(
1224 request: Request,
1225 task: Task,
1226 - keyPath: Root | KeyNode,
1226 + keyPath: KeyNode,
1227 Component: any,
1228 props: any,
1229 ): void {
@@ -1252,7 +1252,7 @@ let hasWarnedAboutUsingContextAsConsumer = false;
1252 function renderIndeterminateComponent(
1253 request: Request,
1254 task: Task,
1255 - keyPath: Root | KeyNode,
1255 + keyPath: KeyNode,
1256 prevThenableState: ThenableState | null,
1257 Component: any,
1258 props: any,
@@ -1379,7 +1379,7 @@ function renderIndeterminateComponent(
1379 function finishFunctionComponent(
1380 request: Request,
1381 task: Task,
1382 - keyPath: Root | KeyNode,
1382 + keyPath: KeyNode,
1383 children: ReactNodeList,
1384 hasId: boolean,
1385 formStateCount: number,
@@ -1506,7 +1506,7 @@ function resolveDefaultProps(Component: any, baseProps: Object): Object {
1506 function renderForwardRef(
1507 request: Request,
1508 task: Task,
1509 - keyPath: Root | KeyNode,
1509 + keyPath: KeyNode,
1510 prevThenableState: null | ThenableState,
1511 type: any,
1512 props: Object,
@@ -1540,7 +1540,7 @@ function renderForwardRef(
1540 function renderMemo(
1541 request: Request,
1542 task: Task,
1543 - keyPath: Root | KeyNode,
1543 + keyPath: KeyNode,
1544 prevThenableState: ThenableState | null,
1545 type: any,
1546 props: Object,
@@ -1562,7 +1562,7 @@ function renderMemo(
1562 function renderContextConsumer(
1563 request: Request,
1564 task: Task,
1565 - keyPath: Root | KeyNode,
1565 + keyPath: KeyNode,
1566 context: ReactContext<any>,
1567 props: Object,
1568 ): void {
@@ -1616,7 +1616,7 @@ function renderContextConsumer(
1616 function renderContextProvider(
1617 request: Request,
1618 task: Task,
1619 - keyPath: Root | KeyNode,
1619 + keyPath: KeyNode,
1620 type: ReactProviderType<any>,
1621 props: Object,
1622 ): void {
@@ -1645,7 +1645,7 @@ function renderContextProvider(
1645 function renderLazyComponent(
1646 request: Request,
1647 task: Task,
1648 - keyPath: Root | KeyNode,
1648 + keyPath: KeyNode,
1649 prevThenableState: ThenableState | null,
1650 lazyComponent: LazyComponentType<any, any>,
1651 props: Object,
@@ -1671,7 +1671,7 @@ function renderLazyComponent(
1671 function renderOffscreen(
1672 request: Request,
1673 task: Task,
1674 - keyPath: Root | KeyNode,
1674 + keyPath: KeyNode,
1675 props: Object,
1676 ): void {
1677 const mode: ?OffscreenMode = (props.mode: any);
@@ -1691,7 +1691,7 @@ function renderOffscreen(
1691 function renderElement(
1692 request: Request,
1693 task: Task,
1694 - keyPath: Root | KeyNode,
1694 + keyPath: KeyNode,
1695 prevThenableState: ThenableState | null,
1696 type: any,
1697 props: Object,
@@ -1882,7 +1882,7 @@ function resumeNode(
1882 function resumeElement(
1883 request: Request,
1884 task: ReplayTask,
1885 - keyPath: Root | KeyNode,
1885 + keyPath: KeyNode,
1886 segmentId: number,
1887 prevThenableState: ThenableState | null,
1888 type: any,
@@ -1926,7 +1926,7 @@ function resumeElement(
1926 function replayElement(
1927 request: Request,
1928 task: ReplayTask,
1929 - keyPath: Root | KeyNode,
1929 + keyPath: KeyNode,
1930 prevThenableState: ThenableState | null,
1931 name: null | string,
1932 keyOrIndex: number | string,