1. Based off the diagram, what happens first, the ‘render’ or the ‘componentDidMount’?
‘Render” is called before componentDidMount.
2. What is the very first thing to happen in the lifecycle of React?
Initialization is the first thing to happen in a lifecycle of React.
3. Put the following things in the order that they happen: componentDidMount
, render
, constructor
, componentWillUnmount
, React Updates
?
Constructor componentWillUnmount render componentDidMount React Updates
4. What does componentDidMount
do?
It is called immediately after componentWillMount and can update the state with an API response and set subscriptions.
1. What types of things can you pass in the props?
We can pass data that we want to pass in externally to props, like arguments to a constructor, for example.
2. What is the big difference between props and state?
Props are like the arguments
of a component in React. We pass props into a component, similarly to how we do with functions.
State, on the other hand, is stored inside a component. State can continually update and rerender. State can only be accessed and modified directly inside its component.
3. When do we re-render our application?
Whenever the state data changes, we re-render.
4. What are some examples of things that we could store in state?
We could store a number counter or the data for the moving hands of a clock, or the value of randomly generated colors in a rainbow component.
state
nor props
is appropriate to handle?