M
M
Maxim2020-06-26 17:16:01
React
Maxim, 2020-06-26 17:16:01

Why can't hooks be used in conditions?

there is a hook rule where there is a condition that you can't use hooks under conditions, who knows why? what will break there if we use them in conditions and why is it important for react to remember the sequence of hooks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
abberati, 2020-06-26
@abberati

Because the internal implementation of hooks is tied to the call queue. That's how it's done. To better understand exactly how, I advise you to look at the talk in which Michael Jackson (not the same one) writes his own implementation of hooks. Here's the link

C
camelCaseVlad, 2020-06-27
@camelCaseVlad

You must love hooks unconditionally.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question