Skip to content

Commit 6047019

Browse files
remove unnecessary keys and streamline component rendering, enhancing code clarity and maintainability.
1 parent a87a111 commit 6047019

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

node_package/src/RSCPayloadContainer.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ const RSCPayloadContainer = ({
5858
dangerouslySetInnerHTML={{
5959
__html: escapeScript(`(self.REACT_ON_RAILS_RSC_PAYLOAD||=[]).push(${chunk.chunk})`),
6060
}}
61-
key={`script-${chunkIndex}`}
6261
/>
6362
);
6463

@@ -69,7 +68,7 @@ const RSCPayloadContainer = ({
6968
return (
7069
<>
7170
{scriptElement}
72-
<React.Suspense fallback={null} key={`suspense-${chunkIndex}`}>
71+
<React.Suspense fallback={null}>
7372
<RSCPayloadContainer chunkIndex={chunkIndex + 1} getChunkPromise={getChunkPromise} />
7473
</React.Suspense>
7574
</>

node_package/src/RSCServerRoot.tsx

+13-12
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,10 @@ const createSSRManifest = async (
4141
loadJsonFile(reactClientManifestFileName) as Promise<Record<string, { id: string }>>,
4242
]);
4343

44-
const ssrManifest = {
45-
// The `moduleLoading` property is utilized by the React runtime to load JavaScript modules.
46-
// It can accept options such as `prefix` and `crossOrigin` to specify the path and crossorigin attribute for the modules.
47-
// In our case, since the server code is bundled into a single bundle, there is no need to load additional JavaScript modules.
48-
// As a result, we set this property to an empty object because it will not be used.
49-
moduleLoading: {},
50-
moduleMap: {} as Record<string, unknown>,
51-
};
52-
44+
const moduleMap: Record<string, unknown> = {};
5345
Object.entries(reactClientManifest).forEach(([aboluteFileUrl, clientFileBundlingInfo]) => {
5446
const { id, chunks } = reactServerManifest[aboluteFileUrl];
55-
ssrManifest.moduleMap[clientFileBundlingInfo.id] = {
47+
moduleMap[clientFileBundlingInfo.id] = {
5648
'*': {
5749
id,
5850
chunks,
@@ -61,6 +53,15 @@ const createSSRManifest = async (
6153
};
6254
});
6355

56+
const ssrManifest = {
57+
// The `moduleLoading` property is utilized by the React runtime to load JavaScript modules.
58+
// It can accept options such as `prefix` and `crossOrigin` to specify the path and crossorigin attribute for the modules.
59+
// In our case, since the server code is bundled into a single bundle, there is no need to load additional JavaScript modules.
60+
// As a result, we set this property to an empty object because it will not be used.
61+
moduleLoading: {},
62+
moduleMap,
63+
};
64+
6465
return ssrManifest;
6566
};
6667

@@ -106,8 +107,8 @@ const RSCServerRoot: RenderFunction = async (
106107
const resolvedServerComponent = use(serverComponentElement);
107108
return (
108109
<>
109-
<React.Fragment key="serverComponentElement">{resolvedServerComponent}</React.Fragment>
110-
<RSCPayloadContainer RSCPayloadStream={rscPayloadStream2} key="rscPayloadContainer" />
110+
{resolvedServerComponent}
111+
<RSCPayloadContainer RSCPayloadStream={rscPayloadStream2} />
111112
</>
112113
);
113114
};

0 commit comments

Comments
 (0)