diff --git a/src/components/Layout/Feedback.tsx b/src/components/Layout/Feedback.tsx index 6bb8a4aac6d..e3f12d0db58 100644 --- a/src/components/Layout/Feedback.tsx +++ b/src/components/Layout/Feedback.tsx @@ -2,7 +2,7 @@ * Copyright (c) Facebook, Inc. and its affiliates. */ -import {useState} from 'react'; +import {useState, useEffect} from 'react'; import {useRouter} from 'next/router'; import {ga} from '../../utils/analytics'; @@ -60,8 +60,30 @@ function sendGAEvent(isPositive: boolean) { function SendFeedback({onSubmit}: {onSubmit: () => void}) { const [isSubmitted, setIsSubmitted] = useState(false); + const [isVisible, setIsVisible] = useState(true); + + useEffect(() => { + let timer: NodeJS.Timeout | null = null; + + if (isSubmitted) { + timer = setTimeout(() => { + setIsVisible(false); + }, 3000); + } + + return () => { + if (timer) { + clearTimeout(timer); + } + }; + }, [isSubmitted]); return ( -
+

{isSubmitted ? 'Thank you for your feedback!' : 'Is this page useful?'}