State and Props


State and Props

React lifecycle

dia

  1. Based off the diagram, what happens first, the ‘render’ or the ‘componentDidMount’?

‘render’ will happen before ‘componentDidMount’ based on the diagram.

  1. What is the very first thing to happen in the lifecycle of React?

The calling for the constructor of React components.

  1. Put the following things in the order that they happen: componentDidMount, render, constructor, componentWillUnmount, React Updates.
  • constructor
  • render
  • componentDidMount
  • React Updates
  • componentWillUnmount
  1. What does componentDidMount do?

To load anything using a network request or initialize the DOM and setting up subscriptions.


React State Vs Props

  1. What types of things can you pass in the props?

props pass variables from one to another component, those variables can be anything from integers over objects to arrays. Even React components.

  1. What is the big difference between props and state?

props are handled outside the component and you need to update it outside, whereas state is quite the opposite, its handled inside the component and you update it there.

  1. When do we re-render our application?

When the user interactively changes the state, the app will re-render to show the new updates.

  1. What are some examples of things that we could store in state?

An interchangeable data, like an outcomes from a form maybe.


Things I want to know more about

  • More about State and Props.
  • a clear picture of how does react actually works.

 

 

 


   

Get back to EMAM’S HOMEPAGE

I have created this page as a part of my project using Github, Please visit my profile, I will be more than happy to hear from you all.                       © Emam Shararah 2021