reading-notes

Reading 2 - State and Props

React Lifecycle

Source: Medium

Q1: Based off the diagram, what happens first, the ‘render’ or the ‘componentDidMount’?

“Render”

Q2: What is the very first thing to happen in the lifecycle of React?

The Mounting Phase

Q3: Put the following things in the order that they happen: componentDidMount, render, constructor, componentWillUnmount, React Updates

  1. constructor

  2. render

  3. React Updates

  4. componentDidMount

  5. componentWillUnmount

Q4: What does componentDidMount do?

The componentDidMount is used for handling network requests and setting up any subscriptions.

Video: React State Vs Props

Source: Web Dev Simplified

Q5: What types of things can you pass in the props?

Similar to an argument in a vanilla JS function, there are a lot of things that can be passed in the props, such as an initial count in counter.

Q6: What is the big difference between props and state?

With state, changes occur inside of the component. With props, changes come from outside the component and receive information from outside the component, such as from a parent component.

Q7: When do we re-render our application?

The application re-renders when there is a change in the component’s state or props

Q8: What are some examples of things that we could store in state?

Data a user inputs, the current value of a counter

Things I want to know more about

How does the lifecycle of react apply to the work we’ve been doing in the labs?