reading-notes

State and Props

Why this topic matters

States and proprs are how components in react manipulate and exchange data. The intraconnectivity of these components is crucial to making an application function, therefor this topic is really important.

React lifecycle

  1. Based off the diagram, what happens first, the render or the componentDidMount?
    render happens first.
  2. What is the very first thing to happen in the lifecycle of React?
    constructor occurs first, and it occurs during the mounting phase.
  3. Put the following things in the order that they happen:
    constructor, render, React Updates, componentDidMount, componentWillUnmount
  4. What does componentDidMount do?
    It is invoked after a component is mounted and it used to load things using a network request or to initialize the DOM

React State Vs Props

  1. What types of things can you pass in the props?
    You pass any information you need to child component. If I understood the video, the state of a component can be passed into a component as props.
  2. What is the big difference between props and state?
    Props are passed into a component and handled outside of the component, while states are handles within a component. Thus props must be updated outside the component, and states and be updated within the component.
  3. When do we re-render our application?
    An application will re-render when the state is updated based on something the user has done.
  4. What are some examples of things that we could store in state?
    Any information that is being manipulated by the user such as a counter or a form.

Things I want to know more about