Reading 301-02

Readings: State and Props

React lifecycle

  1. Based off the diagram, what happens first, the ‘render’ or the ‘componentDidMount’?
    • Render will happen first once shouldComponentUpdate() returns true, then componentDidMount is next
  2. What is the very first thing to happen in the lifecycle of React?
    • The constructor is called before it is mounted
  3. Put the following things in the order that they happen: componentDidMount, render, constructor, componentWillUnmount, React Updates
    • constructor
    • React Updates
    • render
    • componentDidMount
    • componentWillUnmount
  4. What does componentDidMount do?
    • It cleans the DOM and network requests and subscriptons

React State Vs Props

  1. What types of things can you pass in the props?
    • Props are like the pramaters of a function, you can pass a counter
    • Displays info, is a var to a function,
    • Dont change
  2. What is the big difference between props and state?
    • State are handled inside the component and props are handled outside
    • Changing / updating state rerenders the application
  3. When do we re-render our application?
    • When we change something in the state that you stored it will rerender the application
  4. What are some examples of things that we could store in state?
    • short, medium and long term data

Things I want to learn more about

  1. It is interesting how state works, I want to start seeing and using some examples so I can get a better picture of it. I kind of understand props but state seems like youre able to have alot of control and options Web Dev Simplified (YouTube)