Lifecycle methods are methods that get called at certain moments in a component’s life.
There are three categories of lifecycle methods: mounting, updating, and unmounting
There are three mounting lifecycle methods
When a component mounts:
it automatically calls these three methods, in order
ReactJS is handling this methods call when you mount a component, you can use this to your advantage when designing your app.
Impossible to say what exactly interval is without knowing where the example is coming from
componentDidMount is called when a component is rendered for the first time, so this is a good place to start an interval (to start an update cycle to update the element every 5 seconds)
then when the component is removed, componentWillUnmount is called, you clear the interval