State and Props
Index
Home
React Lifecycle
React State Vs Props
React Lifecycle
- Based off the diagram, what happens first, the ‘render’ or the ‘componentDidMount’?
- Render
- What is the very first thing to happen in the lifecycle of React?
- Mounting
- Put the following things in the order that they happen:
componentDidMount,render,constructor,componentWillUnmount,React Updates- Constructor, render, react updates, componentDidMount, componentWillUnmount
- What does
componentDidMountdo?- componentDidMount is invoked immediately after a compenet is mounted and is a good place to load anything using network requests or initialize the DOM.
React State Vs Props
- What types of things can you pass in the props?
- arguments, any value you want to pass into a component/function.
- What is the big difference between props and state?
- Props you pass in and can only be updated outside of the component, state is handled inside a component and can be updated inside the component.
- When do we re-render our application?
- When you want to change something displayed in the application (usualy based on user input).
- What are some examples of things that we could store in state?
- Form data, counters, dynamic statistics (example: changing stockmarket info, weather conditions, etc.)