From 0baaa06f87a9391a0d2edd9fe34532ee7089341b Mon Sep 17 00:00:00 2001 From: Nazar Poshtarenko <32395926+unrenamed@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:40:42 +0200 Subject: [PATCH] fix: resolve 16 of 54 lint warnings (#2652) * fix: adjust useEffect dependencies to prevent lint warnings in button components * fix: remove unused dependencies from useEffects in meteor lines * fix: resolve lint warnings in Particles and ShinyCard components * fix: adjust useEffect dependencies as per coderabbitai comments --------- Co-authored-by: chronark --- .../components/dashboard/copy-button.tsx | 16 ++++++---- .../components/dashboard/visible-button.tsx | 13 +++++--- apps/www/components/copy-button.tsx | 20 +++++++----- apps/www/components/particles.tsx | 27 +++++++++------- apps/www/components/shiny-card.tsx | 31 ++++++++++--------- apps/www/components/ui/copy-code-button.tsx | 15 ++++++--- apps/www/components/ui/meteorLines.tsx | 8 ++--- 7 files changed, 75 insertions(+), 55 deletions(-) diff --git a/apps/dashboard/components/dashboard/copy-button.tsx b/apps/dashboard/components/dashboard/copy-button.tsx index 906888f232..402d88d001 100644 --- a/apps/dashboard/components/dashboard/copy-button.tsx +++ b/apps/dashboard/components/dashboard/copy-button.tsx @@ -15,13 +15,17 @@ async function copyToClipboardWithMeta(value: string, _meta?: Record { - setTimeout(() => { - setHasCopied(false); + if (!copied) { + return; + } + const timer = setTimeout(() => { + setCopied(false); }, 2000); - }, [hasCopied]); + return () => clearTimeout(timer); + }, [copied]); return ( ); } diff --git a/apps/dashboard/components/dashboard/visible-button.tsx b/apps/dashboard/components/dashboard/visible-button.tsx index 8407bd1821..ac7d863e12 100644 --- a/apps/dashboard/components/dashboard/visible-button.tsx +++ b/apps/dashboard/components/dashboard/visible-button.tsx @@ -1,7 +1,6 @@ -import * as React from "react"; - import { cn } from "@/lib/utils"; import { Eye, EyeOff } from "lucide-react"; +import { useEffect } from "react"; type VisibleButtonProps = React.HTMLAttributes & { isVisible: boolean; @@ -14,11 +13,15 @@ export function VisibleButton({ setIsVisible, ...props }: VisibleButtonProps) { - React.useEffect(() => { - setTimeout(() => { + useEffect(() => { + if (!isVisible) { + return; + } + const timer = setTimeout(() => { setIsVisible(false); }, 10000); - }, [isVisible]); + return () => clearTimeout(timer); + }, [setIsVisible, isVisible]); return (