Reading 02
Lifecycle of React Component Article
- Based off the diagram, what happens first, the ‘render’ or the ‘componentDidMount’? Judging from the chart, rendering is occuring first, followed by componentDidMount at the end of the mounting phase.
- What is the very first thing to happen in the lifecycle of React? The mounting phase is the very first step in the lifecycle of a React Component. This is when a component is created and added to the DOM
- Put the following things in the order that they happen: componentDidMount, render, constructor, componentWillUnmount, React Updates constructor, render, componentDidMount, ReactUpdates, componentWillUnmount
- What does componentDidMount do? componentDidMount is used for network requests and anytime a component is first inserted to the DOM. This is where you set up subscriptions/APIs
Props vs States Video
- What types of things can you pass in the props? Any type of data can be passed as a prop. The value of the props, however, can only be changed from the parent, not within the component itself or a child.
- What is the big difference between props and state? As above, props receive their information from parents, whereas with state, the value is managed within itself.
- When do we re-render our application? If a change occurs to either a prop or a state, the applicatoin will be rerendered to output the most current data.
- What are some examples of things that we could store in state? I’m not positive about this one but I understand that data which will be altered over time should be used as ‘state’. This allows the component to manipulate it
Things I Want to Know More About
I need to see state in action. I have a bit of understanding with props from our class-01 Lab. Also, I would like to see how lifecycle would influence the manner in which we code