Is render different for the mounting and updating lifecycle phases?

Question

In the context of this exercise, is render() different for the mounting and updating lifecycle phases?

Answer

For the mounting and updating lifecycle phases, a component will use the same render() method during both. However, the context on which they are called, and their purposes are slightly different for each phase.

During the mounting phase, render() is called exactly once, and is used to render the component for the very first time, essentially creating something that wasn’t there before in the DOM.

During the updating phase, render() is called during every change in props and state of the component, and follows the very first render(). As a result, each render() during this phase of the component lifecycle is essentially a re-render of the component after its initial render.

2 Likes