DEV Community

Discussion on: Building a chat app with Socket.io and React 🚀

Collapse
 
jurrevandenberg profile image
Raccoon

Thank you for the great article. I have one question. When someone is typing it shows the message but I can't figure out how to remove the is typing when the person isn't typing. Do you have an idea?

Collapse
 
shpinat479 profile image
AlexanderShpilka • Edited

I just did this:

useEffect(() => {
    const timer = setTimeout(() => {
      if (typingStatus) {
        setTypingStatus('')
      }
    }, 3000)

    return () => {
      clearTimeout(timer)
    }
}, [typingStatus])
Enter fullscreen mode Exit fullscreen mode