title: How to hide the message after 5 sec using React.js
body: <p>I need to hide the message inside div element after 5 sec of form submit using React.js. I am explaining my code below.</p>
  
  <pre><code>&lt;div className="wrapper"&gt;
              &lt;div ref={divEl =&gt; {
              this.divRef = divEl;
            }}&gt;&lt;/div&gt;
              &lt;form onSubmit={this.addItem}&gt;
                &lt;input ref={(a)=&gt;this.inputElement=a} placeholder="enter task"&gt;
                &lt;/input&gt;
                &lt;button type="submit"&gt;{this.state.editKey? "Update": "Add"}&lt;/button&gt;
              &lt;/form&gt;
              &lt;TodoItems entries={this.state.items} delete={this.deleteItem} edit={this.editItem}/&gt;
            &lt;/div&gt;
  addItem(e){
      e.preventDefault();
      if(this.state.editKey){
        this.saveEditedText();
        return;
      }
      var itemArray = this.state.items;
      if (this.inputElement.value !== '') {
        itemArray.unshift({
          text:this.inputElement.value,
          key:Date.now()
        })
        this.setState({
          items:itemArray
        })
        this.divRef.innerHTML = this.inputElement.value;
        this.inputElement.value='';
        this.divRef.insertAdjacentHTML("beforeend", '&lt;p className="textcolor"&gt;Added successfully&lt;/p&gt;');
      }
    }
  </code></pre>
  
  <p>Here I have after the form is submitting the success message is showing. I need after 5 sec of showing the message will remove automatically means using timeinterval.</p>