Skip to content

Commit

Permalink
chore: Add a cleanup function using clearTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
amiabl-programr committed Sep 17, 2024
1 parent 8e4e3e2 commit 1c31f7a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/islands/recent-searches.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ export default function RecentSearches() {
if (savedSearches) {
$recentSearches.set(savedSearches);
}
setTimeout(()=>{
const timer = setTimeout(() => {
setIsLoading(false);
},2000)
}, 2000);

return () => clearTimeout(timer);
}, []);

if (isLoading) {
Expand Down

0 comments on commit 1c31f7a

Please sign in to comment.