From 0577c5c04f191af5dab74730276fe1925d8045a5 Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Wed, 7 Feb 2024 23:51:55 +0800 Subject: [PATCH] Only reset abortcontroller ref if captured instance is same as ref --- src/useFetch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/useFetch.ts b/src/useFetch.ts index f51f921..cf35a81 100644 --- a/src/useFetch.ts +++ b/src/useFetch.ts @@ -158,7 +158,7 @@ function useFetch(...args: UseFetchArgs): UseFetch { } finally { timedout.current = false if (timer) clearTimeout(timer) - controller.current = undefined + if (controller.current === theController) controller.current = undefined } if (newRes && !newRes.ok && !error.current) error.current = makeError(newRes.status, newRes.statusText)