From d93279c34e7de59e5caee9120074a935de4d0401 Mon Sep 17 00:00:00 2001 From: Nick Adamson Date: Thu, 28 Dec 2023 12:14:09 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(fix):=20stop=20useStream=20from?= =?UTF-8?q?=20opening=20streams=20when=20disabled?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useStream.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hooks/useStream.ts b/src/hooks/useStream.ts index 77e6a54..8c5800f 100644 --- a/src/hooks/useStream.ts +++ b/src/hooks/useStream.ts @@ -142,6 +142,14 @@ export const useStream = < ...queryOptions, queryKey, queryFn: async () => { + if (queryOptions.enabled === false) { + // If the query is disabled, early return empty response + return { + done: true, + responses: [], + }; + } + let responses: O[] = []; const streamId = streamIdRef.current; streamIdRef.current += 1;