diff --git a/packages/react-hooks/src/hooks/useRealtime.ts b/packages/react-hooks/src/hooks/useRealtime.ts index 9492c085de..81e1fdbf45 100644 --- a/packages/react-hooks/src/hooks/useRealtime.ts +++ b/packages/react-hooks/src/hooks/useRealtime.ts @@ -428,6 +428,9 @@ export function useRealtimeRunsWithTag( const apiClient = useApiClient(options); + const stableTag = Array.isArray(tag) + ? JSON.stringify([...tag].sort()) + : tag; const triggerRequest = useCallback(async () => { try { if (!apiClient) { @@ -459,7 +462,7 @@ export function useRealtimeRunsWithTag( abortControllerRef.current = null; } } - }, [tag, mutateRuns, runsRef, abortControllerRef, apiClient, setError]); + }, [stableTag, mutateRuns, runsRef, abortControllerRef, apiClient, setError]); useEffect(() => { if (typeof options?.enabled === "boolean" && !options.enabled) { @@ -471,7 +474,7 @@ export function useRealtimeRunsWithTag( return () => { stop(); }; - }, [tag, stop, options?.enabled]); + }, [stableTag, stop, options?.enabled]); return { runs: runs ?? [], error, stop }; }