You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Creates a unique cache key for RSC payloads to prevent collisions between component instances.
15
+
*
16
+
* This function generates cache keys that ensure:
17
+
* 1. Different components have different keys
18
+
* 2. Same components with different props have different keys
19
+
* 3. Multiple instances of the same component on the same rails view have different keys
20
+
*
21
+
* @param componentName - Name of the React Server Component
22
+
* @param componentProps - Props passed to the component (serialized to JSON)
23
+
* @param domNodeId - DOM node ID of the parent react component rendered at the rails view (prevents instance collisions)
24
+
* @returns A unique cache key string
25
+
* @throws Error if domNodeId is missing, which could lead to cache collisions
26
+
*/
13
27
exportconstcreateRSCPayloadKey=(
14
28
componentName: string,
15
29
componentProps: unknown,
16
30
domNodeId: string|undefined,
17
31
)=>{
18
32
if(!domNodeId){
19
-
console.warn(
20
-
'Warning: domNodeId is required when using React Server Components to ensure unique RSC payload caching and prevent conflicts between multiple instances of the same component.',
21
-
);
33
+
consterrorMessage=
34
+
'domNodeId is required when using React Server Components to ensure unique RSC payload caching '+
35
+
'and prevent conflicts between multiple instances of the same component at the same rails view. '+
36
+
'This could lead to incorrect hydration and component state issues.';
0 commit comments