Skip to content

Commit 6547616

Browse files
Renamed createRSCPayloadKey to createServerComponentCacheKey
1 parent a7deca6 commit 6547616

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

node_package/src/RSCProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import type { ClientGetReactServerComponentProps } from './getReactServerComponent.client.ts';
3-
import { createRSCPayloadKey } from './utils.ts';
3+
import { createServerComponentCacheKey } from './utils.ts';
44

55
type RSCContextType = {
66
getComponent: (componentName: string, componentProps: unknown) => Promise<React.ReactNode>;
@@ -37,7 +37,7 @@ export const createRSCProvider = ({
3737
const fetchRSCPromises: Record<string, Promise<React.ReactNode>> = {};
3838

3939
const getComponent = (componentName: string, componentProps: unknown) => {
40-
const key = createRSCPayloadKey(componentName, componentProps);
40+
const key = createServerComponentCacheKey(componentName, componentProps);
4141
if (key in fetchRSCPromises) {
4242
return fetchRSCPromises[key];
4343
}
@@ -48,7 +48,7 @@ export const createRSCProvider = ({
4848
};
4949

5050
const refetchComponent = (componentName: string, componentProps: unknown) => {
51-
const key = createRSCPayloadKey(componentName, componentProps);
51+
const key = createServerComponentCacheKey(componentName, componentProps);
5252
const promise = getServerComponent({
5353
componentName,
5454
componentProps,

node_package/src/getReactServerComponent.client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { createFromReadableStream } from 'react-on-rails-rsc/client.browser';
3-
import { createRSCPayloadKey, fetch, wrapInNewPromise, extractErrorMessage } from './utils.ts';
3+
import { createServerComponentCacheKey, fetch, wrapInNewPromise, extractErrorMessage } from './utils.ts';
44
import transformRSCStreamAndReplayConsoleLogs from './transformRSCStreamAndReplayConsoleLogs.ts';
55
import { RailsContext } from './types/index.ts';
66

@@ -165,7 +165,7 @@ const createFromPreloadedPayloads = (payloads: string[]) => {
165165
const getReactServerComponent =
166166
(domNodeId: string, railsContext: RailsContext) =>
167167
({ componentName, componentProps, enforceRefetch = false }: ClientGetReactServerComponentProps) => {
168-
const componentCacheKey = createRSCPayloadKey(componentName, componentProps);
168+
const componentCacheKey = createServerComponentCacheKey(componentName, componentProps);
169169

170170
const rscPayloadKey = `${componentCacheKey}-${domNodeId}`;
171171
const payloads = window.REACT_ON_RAILS_RSC_PAYLOADS?.[rscPayloadKey];

node_package/src/injectRSCPayload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { PassThrough } from 'stream';
22
import { finished } from 'stream/promises';
3-
import { createRSCPayloadKey } from './utils.ts';
3+
import { createServerComponentCacheKey } from './utils.ts';
44
import { PipeableOrReadableStream } from './types/index.ts';
55
import RSCRequestTracker from './RSCRequestTracker.ts';
66

@@ -210,7 +210,7 @@ export default function injectRSCPayload(
210210

211211
rscRequestTracker.onRSCPayloadGenerated((streamInfo) => {
212212
const { stream, props, componentName } = streamInfo;
213-
const cacheKey = createRSCPayloadKey(componentName, props);
213+
const cacheKey = createServerComponentCacheKey(componentName, props);
214214
const rscPayloadKey = `${cacheKey}-${domNodeId}`;
215215

216216
// CRITICAL TIMING: Initialize global array IMMEDIATELY when component requests RSC

node_package/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export { customFetch as fetch };
2121
* @param componentProps - Props passed to the component (serialized to JSON)
2222
* @returns A unique cache key string
2323
*/
24-
export const createRSCPayloadKey = (componentName: string, componentProps: unknown) => {
24+
export const createServerComponentCacheKey = (componentName: string, componentProps: unknown) => {
2525
return `${componentName}-${JSON.stringify(componentProps)}`;
2626
};
2727

0 commit comments

Comments
 (0)