Chapter 6. The React Component Lifecycle
The goal of this chapter is for you to learn about the lifecycle of React components and how to write code that responds to lifecycle events. We'll kick things off with a brief discussion on why components need a lifecycle in the first place. Then, you'll implement several example components that initialize their properties and state using these methods.
Next, you'll learn about how to optimize the rendering efficiency of your components by avoiding rendering when it isn't necessary. Finally, you'll see how to encapsulate imperative code in React components and how to clean up when components are unmounted.