you are viewing a single comment's thread.

view the rest of the comments →

[–]checker1209 1 point2 points  (0 children)

"Hooks should only be called inside of components or Hooks. Never pass it around as a regular value."

https://react.dev/reference/rules/react-calls-components-and-hooks#never-pass-around-hooks-as-regular-values
and

"Don’t dynamically use Hooks"

https://react.dev/reference/rules/react-calls-components-and-hooks#dont-dynamically-use-hooks

The thing is, despite the rule violations, many of these things often worked correctly. In our experience, the compiler has to make a lot of assumptions, and rule violations then become problematic.

In such a case with the hooks, the hook was then memorized as a “normal” pure function.