The Update Lifecycle
The update
loop segment of the lifecycle is something that lives for the entire lifetime of the component (where the lifetime of a component is if it needs to be displayed in the DOM). This loop repeats every time that the component needs to be updated, which is basically whenever any data that affects what needs to be loaded and displayed as the DOM changes which will then start a lifecycle method specifically to determine what changes need to be displayed. For example, if you modify the shouldComponentUpdate()
lifecycle function to just always return false
, then as far as React is concerned, no changes should ever retrigger the update loop. Similarly, if you always return true
, like we did in our first exercise, then React will assume every state or props change needs to retrigger re-rendering.
render()
We have already discussed the render
function, but it is worth mentioning that this is when the render
function gets called each time the component updates...