Why do we need to understand the ReactJs life cycle methods?

Why do we need to understand the ReactJs life cycle methods?  #javascript

  • When you build an application in ReactJs you will have to split the UI into reusable components and think about each of them in isolation.When the user interacts with our application in ReactJs, for example, by hovering, pressing a key, clicking… These actions trigger many other events on the UI…
  • So, why is understanding lifecycle methods so important?Let’s imagine that you are building an application in ReactJs, for example, a video player app, like Vimeo, Twitch or Youtube .
  • Now, your user is using the player app on his/her laptop and decides to search for a fun video to watch, found the video, and then selected to watch it.Let’s suppose that the player app is consuming only resources like network data and the battery power.After some time watching videos…
  • When we build an application in ReactJs , we can predict different type of actions by the user, placing some hooks and triggers.These triggers and hooks are available by component lifecycle methods in Reactjs.
  • They will help us to create the most efficient piece of the software as possible.To place correctly the hook methods into the components we need to learn more about the four stages of ReactJs component.The ReactJs component goes through the Four following is a little diagram to demonstrate those phases.InitializationIn…

Components are the core of ReactJs. When you build an application in ReactJs you will have to split the UI into reusable components and think about each of them in isolation. When the user interacts…

Why do we need to understand the ReactJs life cycle methods?

Components are the core of ReactJs. When you build an application in ReactJs you will have to split the UI into reusable components and think about each of them in isolation.

When the user interacts with our application in ReactJs, for example, by hovering, pressing a key, clicking… These actions trigger many other events on the UI components.

There are many trigger methods for the UI components and they can be invoked at different stages and phases during a lifecycle of a component.

The four stages of the component lifecycle are Initialization, Mounting, Updating and Unmounting.

It’s very important to know that the component lifecycle phases can only be created in stateful components or class components.

That being said, lifecycle methods can not be used in stateless components, for the simple reason that these components do not manipulate state.

Later on, I will write a blog post explaining the differences and advantages between class components (stateful components) and stateless components (functional components).

Let’s imagine that you are building an application in ReactJs, for example, a video player app, like Vimeo, Twitch or Youtube .

Now, your user is using the player app on his/her laptop and decides to search for a fun video to watch, found the video, and then selected to watch it.

Let’s suppose that the player app is…

Why do we need to understand the ReactJs life cycle methods?