From 2676795e487d7edb2135624538d57b98d3ca2493 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 21 Feb 2022 13:19:46 +0100 Subject: [PATCH] fix timeouts --- libs/remix-ui/search/src/lib/components/Exclude.tsx | 5 +++-- libs/remix-ui/search/src/lib/components/Include.tsx | 5 +++-- libs/remix-ui/search/src/lib/components/Replace.tsx | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libs/remix-ui/search/src/lib/components/Exclude.tsx b/libs/remix-ui/search/src/lib/components/Exclude.tsx index c836183157..c6bdef48e2 100644 --- a/libs/remix-ui/search/src/lib/components/Exclude.tsx +++ b/libs/remix-ui/search/src/lib/components/Exclude.tsx @@ -4,10 +4,11 @@ import { SearchContext } from '../context/context' export const Exclude = props => { const { setExclude, state } = useContext(SearchContext) const [str, setStr] = useState('.git/**/*,.deps/**/*') + let timeOutId: any = null const change = e => { setStr(e.target.value) - const timeOutId = setTimeout(() => setExclude(e.target.value), 500) - return () => clearTimeout(timeOutId) + clearTimeout(timeOutId) + timeOutId = setTimeout(() => setExclude(e.target.value), 500) } useEffect(() => { diff --git a/libs/remix-ui/search/src/lib/components/Include.tsx b/libs/remix-ui/search/src/lib/components/Include.tsx index a59dd11988..00bf266deb 100644 --- a/libs/remix-ui/search/src/lib/components/Include.tsx +++ b/libs/remix-ui/search/src/lib/components/Include.tsx @@ -3,9 +3,10 @@ import { SearchContext } from '../context/context' export const Include = props => { const { setInclude } = useContext(SearchContext) + let timeOutId: any = null const change = e => { - const timeOutId = setTimeout(() => setInclude(e.target.value), 500) - return () => clearTimeout(timeOutId) + clearTimeout(timeOutId) + timeOutId = setTimeout(() => setInclude(e.target.value), 500) } return ( diff --git a/libs/remix-ui/search/src/lib/components/Replace.tsx b/libs/remix-ui/search/src/lib/components/Replace.tsx index 504261cfa9..33b9ba2539 100644 --- a/libs/remix-ui/search/src/lib/components/Replace.tsx +++ b/libs/remix-ui/search/src/lib/components/Replace.tsx @@ -3,9 +3,10 @@ import { SearchContext } from '../context/context' export const Replace = props => { const { setReplace } = useContext(SearchContext) + let timeOutId: any = null const change = e => { - const timeOutId = setTimeout(() => setReplace(e.target.value), 500) - return () => clearTimeout(timeOutId) + clearTimeout(timeOutId) + timeOutId = setTimeout(() => setReplace(e.target.value), 500) } return (