mostrando erro por alguns segundos reagir

const [visible, setVisible] = useState(false)

useEffect(() => {
  // message is empty (meaning no errors). Adjust as needed
  if(!message){
    setIsVisible(false)
    return
  }
  // error exists. Display the message and hide after 5 secs
  setIsVisible(true)
  const timer = setTimeout(() => {
     setIsVisible(false)
  }, 5000);
  return () => clearTimeout(timer);
}, [message]) // executes every time `message` changes. Adjust as needed
Inquisitive Iguana