Why Do React Hooks Rely on Call Order?

文章就是在讲 Why Do React Hooks Rely on Call Order, 重点在比较几种对于 React 团队的 Hooks 提案的社区改进意见的问题(flaw):

  • Flaw #1: Can’t Extract a Custom Hook
  • Flaw #2: Name Clashes
  • Flaw #3: Can’t Call the Same Hook Twice
  • Flaw #4: The Diamond Problem
  • Flaw #5: Copy Paste Breaks Things
  • Flaw #6: We Still Need a Linter
  • Flaw #7: Can’t Pass Values Between Hooks
  • Flaw #8: Too Much Ceremony

额外学到的知识

  • The diamond problem: The “diamond problem” (sometimes referred to as the “Deadly Diamond of Death”) is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If there is a method in A that B and C have overridden, and D does not override it, then which version of the method does D inherit: that of B, or that of C?
  • Mixins cause name clashes

React hooks: not magic, just arrays

很清晰,但是还是得看源码。

以上。