'when I use setTimeout for show user is typing or not then its working but its blinking when I am typing continuously

I am using setTimeout and its working but when I am typing continuously then also its blinking

How I can solve It ?

messageHandler(ev) {    
    const message = checkText(ev.target.value);
    this.setState({ message });
    let timeout;
      this.props.socket.emit('typing', true);
      timeout = setTimeout(() => {
        this.props.socket.emit('typing', false);
      }, 5000);
  }
 <TextField
              id="messageText"
              className="sendMessageTextfield"
              placeholder="Type a messsage..."
              margin="normal"
              value={this.state.message}
              variant="outlined"
              fullWidth
              multiline
              maxRows={3}
              inputProps={{ 'aria-label': 'bare', maxLength: '10000' }}
              onChange={this.messageHandler.bind(this)}
              onKeyDown={this.keyPressed.bind(this)}
            />

enter image description here

enter image description here Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source