Getting Started with React Hooks:;

Priyansh Darji
2 min readJun 18, 2021

React Hooks is a state management system for react components, which are a new feature addition React version 16.8. They provide the same functionality as React Lifecycle methods which are generally used when code is written using class-based components. Hence when you are using function-based components, Hooks are the goto solution for state management in your Web application. React Hooks provide a cleaner code architecture compared to Lifecycle Methods due to which it becomes Easier to understand the code, Especially when you re-visit your code after sometime. The main advantages
of using Hooks over Lifecycle Methods are as follows:-

1) It eliminates the verbose practice of using JavaScript this keyword every time when you have to access a particular State.
2) It Allows you to use stateful logic.
3) It organizes the logic inside a component into reusable isolated units

Furthermore, Hooks also provide the amazing feature to create any custom hook that you want according to your convenience. That
is for example, You are creating a personal project in which there is a certain functionality that you want to implement at various places
in your project. Thus it doesn’t make any sense to copy paste the same fixed lines of code everytime as it will violate the DRY principle.
Here the custom hooks feature comes very handy, which we will discuss in some another article.

Various Hooks exist in the React Library each of which provide different functionalities for different scenarios, but below listed are the Hooks which are used majority of the times that can cater each and every need that one might come across.

1) useState.
2) useEffect.
3) useReducer.
4) useContext.
5) useMemo.
6) useCallback.
7) useRef.

--

--