Reading 301-02
Readings: State and Props
React lifecycle
- Based off the diagram, what happens first, the ‘render’ or the ‘componentDidMount’?
- Render will happen first once shouldComponentUpdate() returns true, then componentDidMount is next
- What is the very first thing to happen in the lifecycle of React?
- The constructor is called before it is mounted
- Put the following things in the order that they happen: componentDidMount, render, constructor, componentWillUnmount, React Updates
- constructor
- React Updates
- render
- componentDidMount
- componentWillUnmount
- What does componentDidMount do?
- It cleans the DOM and network requests and subscriptons
React State Vs Props
- 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
- 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
- When do we re-render our application?
- When we change something in the state that you stored it will rerender the application
- 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
- 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)