Functions that called while the component is rendered for the first time (mount), or about to be removed from the DOM (unmount).
- componentWillMount()// called before component rendered
- render()// comment box is mounted
- Component waits for API response and when it's received, setState() is called, causing render() to be called again.
- componentDidMount()//called when component done rendering. this._fetchComments() triggered every 5 seconds
- componentWillUnmount()// called when the component is about to be removed from the DOM, and clears the fetchComment timeout