From f48846a6ddfaaa78b29829a6a019fc4cd13e723c Mon Sep 17 00:00:00 2001 From: Lucas Stoebner Date: Tue, 18 Oct 2022 13:26:49 +0200 Subject: [PATCH] =?UTF-8?q?:children=5Fcrossing:=20R=C3=A9initialisation?= =?UTF-8?q?=20du=20bouton=20copi=C3=A9=20apr=C3=A8s=203=20secondes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Félix Legrelle --- site/source/pages/integration/Iframe.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/site/source/pages/integration/Iframe.tsx b/site/source/pages/integration/Iframe.tsx index 6c55a8d06..4eceb2d9a 100644 --- a/site/source/pages/integration/Iframe.tsx +++ b/site/source/pages/integration/Iframe.tsx @@ -330,6 +330,21 @@ function IntegrationCode({ .catch(() => setCopied(false)) } + useEffect(() => { + // Réinitialise l'état de la copie après 3 secondes + let timeout: NodeJS.Timeout + if (copied) { + timeout = setTimeout(() => setCopied(false), 3000) + } + + return () => clearTimeout(timeout) + }, [copied]) + + useEffect(() => { + // Si le code change, on réinitialise l'état de la copie + setCopied(false) + }, [module, color]) + return (