From the course: React: Components, Context, and Accessibility

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

New component lifecycle

New component lifecycle - React.js Tutorial

From the course: React: Components, Context, and Accessibility

Start my 1-month free trial

New component lifecycle

- [Instructor] Whenever you create a React component, there are several life cycle methods that you can use to execute code at particular moments in the life span of a component. Now if you have the life cycle methods that we have used in the past will be deprecated in React 17. For that reason, I'm just going to talk about the ones that will work in the foreseeable future and some new ones that were introduced with React 16. The most recognizable and the most used method of the component life cycle is Render. Render is called when the component is first mounted, but it's also called when new props come in or when Set State is called. The mounting life cycle also includes the following: we have the constructor, this is called before the component is mounted and is a place to initialize state. We also have getDerivedStateFromProps in the mounting life cycle. This is invoked right after the component is constructed. And then finally we have component DidMount, which is called right…

Contents