DEV Community

Dev Learner
Dev Learner

Posted on

Hooks

React's new feature is the React hook.It has made many difficult things easier since it came. The hook can be compared to a hook. The hook helps to hold something in place, just as the hook holds something in place.We can store any data in external file in the form of stat with the help of hook. We can use this data by calling Hook as we need. This increases the mobility of the web.Hook is a method that does not require any kind of function. It can only be used in React. It cannot be used in ordinary JavaScript.To use the hook you have to call it at the beginning of the reaction.
The hook does not work inside a function or inside a loop or anywhere else.
So everyone has to call the start hook.

Pre-requisites for React Hooks
Node version 6 or above
NPM version 5.2 or above
Create-react-app tool for running the React App.

Custom Hooks
A custom Hook is a JavaScript function. The name of custom Hook starts with "use" which can call other Hooks. A custom Hook is just like a regular function, and the word "use" in the beginning tells that this function follows the rules of Hooks. Building custom Hooks allows you to extract component logic into reusable functions.

Top comments (0)