Skip to main content

Command Palette

Search for a command to run...

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

Updated
1 min read
What are the rules that must be followed while
using React Hooks?
R

Full Stack Developer with a passion for building web applications. PHP, Node.js, Laravel, MySQL, MongoDB. Love collaborating & making a difference

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. https://reactjs.org/docs/hooks-rules.html

More from this blog

R

Raja Muhammad Asher - Senior Software Engineer - Full Stack Developer

157 posts

Full Stack Developer with a passion for building web applications. PHP, Node.js, Laravel, ExpressJS, MySQL, MongoDB. Love collaborating & making a difference