To keep it short, my mentors at my current organization introduced me to the wonderful world of React, and I’ve been obsess with learning as much as I can about it. React Hooks were, without a question, one of the most interesting things for me.
What are hooks in React?
Hooks were first implemented in React 16.8. They enable you to utilize state and other React features in a Functional Component, which is one of their most excellent and well-known features.
Hooks are methods that actually “hook into,” React state and lifecycle features from functional components.
How Hooks work?
Let’s define closure before we go into how React hooks function.
“While a function is able to remember and access its lexical scope even when it is operating beyond its lexical scope, that function is said to be closure.”
Things to Remeber
- Hooks always be call at the top level at all times.
This rule ensures that Hooks are call in the same order as they were define each time your component renders. (Keep in mind that you should never call the hooks from within nested functions or loops.)
- Call Hooks from React Function components.
- Call Hooks from custom Hooks.
You can’t seem to get enough of studying about hooks? More articles on types, examples, usages, and other areas of learning the art of utilizing hooks you can see from my other articles. Basic hooks in React and How to create custom hooks. And if you want to know more about react then please visit react official documentation.