diff --git a/packages/react-hooks/src/hooks/useRealtime.ts b/packages/react-hooks/src/hooks/useRealtime.ts index 9492c085de..3e24e2eb36 100644 --- a/packages/react-hooks/src/hooks/useRealtime.ts +++ b/packages/react-hooks/src/hooks/useRealtime.ts @@ -78,17 +78,19 @@ export function useRealtimeRun( const idKey = options?.id ?? hookId; // Store the streams state in SWR, using the idKey as the key to share states. - const { data: run, mutate: mutateRun } = useSWR>([idKey, "run"], null); + const { data: run, mutate: mutateRun } = useSWR>([idKey, "run"], null, { fetcher: () => undefined as any }); const { data: error = undefined, mutate: setError } = useSWR( [idKey, "error"], - null + null, + { fetcher: () => undefined as any } ); // Add state to track when the subscription is complete const { data: isComplete = false, mutate: setIsComplete } = useSWR( [idKey, "complete"], - null + null, + { fetcher: () => undefined as any } ); // Abort controller to cancel the current API call. @@ -228,6 +230,7 @@ export function useRealtimeRunWithStreams< [idKey, "streams"], null, { + fetcher: () => undefined as any, fallbackData: initialStreamsFallback, } ); @@ -239,17 +242,19 @@ export function useRealtimeRunWithStreams< }, [streams]); // Store the streams state in SWR, using the idKey as the key to share states. - const { data: run, mutate: mutateRun } = useSWR>([idKey, "run"], null); + const { data: run, mutate: mutateRun } = useSWR>([idKey, "run"], null, { fetcher: () => undefined as any }); // Add state to track when the subscription is complete const { data: isComplete = false, mutate: setIsComplete } = useSWR( [idKey, "complete"], - null + null, + { fetcher: () => undefined as any } ); const { data: error = undefined, mutate: setError } = useSWR( [idKey, "error"], - null + null, + { fetcher: () => undefined as any } ); // Abort controller to cancel the current API call. @@ -402,6 +407,7 @@ export function useRealtimeRunsWithTag( // Store the streams state in SWR, using the idKey as the key to share states. const { data: runs, mutate: mutateRuns } = useSWR[]>([idKey, "run"], null, { + fetcher: () => undefined as any, fallbackData: [], }); @@ -413,7 +419,8 @@ export function useRealtimeRunsWithTag( const { data: error = undefined, mutate: setError } = useSWR( [idKey, "error"], - null + null, + { fetcher: () => undefined as any } ); // Abort controller to cancel the current API call. @@ -500,6 +507,7 @@ export function useRealtimeBatch( // Store the streams state in SWR, using the idKey as the key to share states. const { data: runs, mutate: mutateRuns } = useSWR[]>([idKey, "run"], null, { + fetcher: () => undefined as any, fallbackData: [], }); @@ -511,7 +519,8 @@ export function useRealtimeBatch( const { data: error = undefined, mutate: setError } = useSWR( [idKey, "error"], - null + null, + { fetcher: () => undefined as any } ); // Abort controller to cancel the current API call.