Skip to content

Commit 92aa907

Browse files
generate rsc payload key only if needed
1 parent 9bebfc4 commit 92aa907

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

node_package/src/getReactServerComponent.client.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,12 @@ const createFromPreloadedPayloads = (payloads: string[]) => {
165165
const getReactServerComponent =
166166
(domNodeId: string, railsContext: RailsContext) =>
167167
({ componentName, componentProps, enforceRefetch = false }: ClientGetReactServerComponentProps) => {
168-
const rscPayloadKey = createRSCPayloadKey(componentName, componentProps, domNodeId);
169-
const payloads = window.REACT_ON_RAILS_RSC_PAYLOADS?.[rscPayloadKey];
170-
if (!enforceRefetch && payloads) {
171-
return createFromPreloadedPayloads(payloads);
168+
if (!enforceRefetch && window.REACT_ON_RAILS_RSC_PAYLOADS) {
169+
const rscPayloadKey = createRSCPayloadKey(componentName, componentProps, domNodeId);
170+
const payloads = window.REACT_ON_RAILS_RSC_PAYLOADS[rscPayloadKey];
171+
if (payloads) {
172+
return createFromPreloadedPayloads(payloads);
173+
}
172174
}
173175
return fetchRSC({ componentName, componentProps, railsContext });
174176
};

0 commit comments

Comments
 (0)