Vargas' Podcasts

Powered by 🌱Roam Garden

Pair Writing on React Hooks

  • Blog Post Archived
  • Notes
    • Ask Zachary Fleischmann about this
      • Why does he hate hooks?
    • Outline
      • Intro
      • What are React Hooks
        • Local component state that responds to changes during rendering
      • Pro 1
        • No longer have to think about React's lifecycle methods, which was a source of many bugs. This gets us closer to the declarative asymptote
      • Con 1
      • Pro 2
        • Components are no longer "stateful" in that they no longer need this or redux. All local state that a component uses could stay local to the component itself without nasty side effects. Dependencies also allows this to be more performant.
      • Con 2
      • Outro
  • Content {{word-count}}
    • React Conf in October 2018 introduced hooks - a feature that have garnered a range of reactions from excitement to frustration. The design pattern it introduced can come across as non intuitive, creating a learning curve that some developers don't bother with overcoming.
    • This article will explore this feature in pair programming fashion. Zakk and I each talk about our experiences with hooks to help you decide whether you should start using hooks in your application
    • What are Hooks?
    • React's official overview is a great place to start when learning about hooks. In summary, hooks are a way to hook into component state from within the context of a function.
    • There are several hooks that come out of the box from React. The main three being:
      • useState - initiate a state variable
      • useCallback - initiate a local function
      • useEffect - run an effect after render
    • Hooks are composable. So you could define your own custom hooks as a combination of various existing hooks to be used in your components.
    • Hooks are completely optional. React has no plans to get rid of class components so you could still create full scale applications without ever using hooks. Here are some things to consider when deciding whether or not to use hooks.
    • Pro - No more lifecycle methods
    • Con -
    • Pro - Components Are More Reusable
    • Con -
Pair Writing on React Hooks