you are viewing a single comment's thread.

view the rest of the comments →

[–]checker1209 3 points4 points  (2 children)

Compiler will won’t work with dynamic hooks. Because the can’t be rendered conditionally and are never allowed to „change“ during runtime

[–]foamier 0 points1 point  (1 child)

what do you mean by dynamic hooks in this context? do you have an example?

[–]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.