Posts

Showing posts from December, 2021
  Lifecycle of Components Each component in React has a lifecycle which you can monitor and manipulate during its three main phases. The three phases are:  Mounting ,  Updating , and  Unmounting . Mounting Mounting means putting elements into the DOM. React has four built-in methods that gets called, in this order, when mounting a component: constructor() getDerivedStateFromProps() render() componentDidMount() The  render()  method is required and will always be called, the others are optional and will be called if you define them. constructor The  constructor()  method is called before anything else, when the component is initiated, and it is the natural place to set up the initial  state  and other initial values. The  constructor()  method is called with the  props , as arguments, and you should always start by calling the  super(props)  before anything else, this will initiate the parent's constructor method ...