From 8f4b431ee36d0521b9aceefe90022c0f742ea306 Mon Sep 17 00:00:00 2001 From: skinmaker1345 Date: Mon, 4 Mar 2024 23:43:54 +0900 Subject: [PATCH] chore: abort on state change --- components/Search.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/Search.tsx b/components/Search.tsx index e1e6b6f5a3..2e0e4f7d14 100644 --- a/components/Search.tsx +++ b/components/Search.tsx @@ -61,6 +61,12 @@ const Search: React.FC = () => { }, 1000) return () => { clearTimeout(timeout) + try { + abortController.current?.abort() + abortController.current = null + } catch (e) { + return null + } } }, [query])