Why hooks are the best thing to happen to React

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • Appwrite - The Open Source Firebase alternative introduces iOS support
  • Scout APM - Less time debugging, more time building
  • SonarQube - Static code analysis for 29 languages.
  • react-universal-hooks

    :tada: React Universal Hooks : just use****** everywhere (Functional or Class Component). Support React DevTools!

    I don’t really understand the authors reasoning either. Classes in JavaScript are just sugar around functional closures.

    In fact, you can use hooks inside of React component subclasses with a little fiddling [1].

    The fact that the official react doesn’t support it is basically a design decision. It’s not impossible, but they just want to draw a clear line in the sand about how they think React code should be written.

    1. https://www.npmjs.com/package/react-universal-hooks

  • React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

    >because under the hood the React runtime is storing all the hooks you call in an array and firing them off by iterating through the array.

    I must correct this. Pay attention to this function [0]

    It's just a plain linked list and nothing is being fired off by iterating through the linked list. When you call a hook react either creates a new node in the linked list or it pops the current head off the linked list so that the second hook will get the second element, the third hook the third element and so on.

    The hooks are fired off by calling them. React isn't calling them again. Each render simply calls your component function and your function calls the hooks which runs a reducer [1] on the internal queue of the hook to compute the latest state. The second return value is just pushing elements into the internal hook queue.

    [0] https://github.com/facebook/react/blob/e07039bb61e3d006ad552...

    [1] https://github.com/facebook/react/blob/e07039bb61e3d006ad552...

  • Appwrite

    Appwrite - The Open Source Firebase alternative introduces iOS support . Appwrite is an open source backend server that helps you build native iOS applications much faster with realtime APIs for authentication, databases, files storage, cloud functions and much more!

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts