View on GitHub

reading-notes

Daily Reading 2

State and Props

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

Render occurs first.

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

constructor() is called, prior to its mounting.

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

Constructor, render, componentDidMount, React Updates, ComponentWillUnmount.

What does componentDidMount do?

ComponentDidMount is called immediately upon a component being mounted, before anything else is done, so code placed there will be executed immediately after component mounting.

React State Vs Props

What types of things can you pass in the props?

values that can be used by other functions. Strings, bools, numbers.

What is the big difference between props and state?

Props can be handed off into a component, while a state cannot, remaining always within the component it was defined in. Props are only updated as well outside of a component, while states are only updated within a component.

When do we re-render our application?

Whenever a state is changed, the application is re-rendered to reflect the new values the state has.

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

Values that are subject to change, that must be displayed to the user. Each time the value changes, the state updating causes a render cycle to execute, allowing the display to reflect the new value the state has.

Back To Main Page.