Reading 28 Props and State - liz-kavalski-401-advanced-javascript/seattle-javascript-401n13 GitHub Wiki

Understanding React setState

  • State can be anything
  • React components with state render UI based on that state, if the state change so does the UI
  • setState() is the only legitimate way to update state after the initial state setup.
  • The reconciliation process is the way React updates the DOM, by making changes to the component based on the change in state.

Functional vs class components

  • A functional component is just a plain JavaScript function which accepts props as an argument and returns a React element.
  • A class component requires you to extend from React.Component and create a render function which returns a React element.
    • requires more code.
  • If you need a state in your component you will either need to create a class component or you lift the state up to the parent component and pass it down the functional component via props.
  • Use functional components if you are writing a presentational component which doesn’t have its own state or needs to access a lifecycle hook.

Handling events

Forms