What are the rules that must be followed while using React Hooks?

Only Call Hooks at the Top Level

Don’t call Hooks inside loops, conditions, or nested functions.

Only Call Hooks from React Functions

Don’t call Hooks from regular JavaScript functions.

Sources:

Rules of Hooks –. (n.d.). React. reactjs.org/docs/hooks-rules.html