React Hooks

Readings

  1. Why React hooks? (35 minute talk)

  2. What are React hooks?

    • Special functions that can store data (like state) or perform functions (side effects) among other things
  3. Hooks flow diagram

    • A diagram that shows when different hooks are called and the order in which they’re called
    • Slight changes after React 17
  4. Lift the state up

    • Technique to share code between two sibling components
  5. State Colocation

    • It means to put your state as close as possible to where it's being used
    • State Colocation will make your React app faster
    • "One of the leading causes to slow React applications is global state, especially the rapidly changing variety."
  6. Don't sync states, derive it!

    • It's usually better to calculate states (deriving) based on other states when you can as opposed to storing them

Notes

  • What is an error boundary and what is it for?
  • Can you do something like
    • useEffect(async () => await doSomething())?
    • Why or why not? If not, what should we do instead?
  • Does React batch state update functions when using hooks? Is the behavior the same for Promise calls? Could this change in the future?
  • Why did Kent say Stop Using isLoading booleans?
  • What is the difference between the following:
    • fetch().then(result => result, error => error)
    • fetch().then(result => result).catch(error => error)
  • Public Class Fields with React Components
  • The npm package bvaughn/react-error-boundary
  • React Hooks Best Practices