React Hooks

Lancer Abir
2 min readNov 5, 2020

--

React Hooks

# What is React Hooks?

Even a few days ago, if React.js was a functional add-on only through class-based components. But since React 16.8 the functional components have started using some of their own Hooks and this has made React very easy to manage.

# What we can do using React Hooks?

~ the functional component state can be managed
~ The side effect can be managed
~ You can work with context
~ the ref can be worked with,
~ You can work with a call-back
~ memo can be done

# Rules for using React Hooks

There are two rules for using React Hooks

i) No function hooks can be used
ii) React Hooks will have multiple functions but not all functions React Hooks can be used, only react component and custom component React Hooks can be used.

# React Hooks API Reference

React Hooks API references are generally of two types

i) Basic Hooks
ii) Additional Hooks

i) Basic Hooks এর মধ্যে রয়েছে

  • useState
  • useEffect
  • useContext

ii) Additional Hooks এর মধ্যে রয়েছে

  • useReducer
  • useCallback
  • useMemo
  • useRef
  • useImperativeHandle
  • useLayoutEffect
  • useDebugValue

# useState Hooks

The function of holding the state is to useState Hooks. UseState Hooks to hold any object, primitive value, array.

# useEffect Hooks

UseEffect Hooks to manage JSON data or any other data from API.

# useContext Hooks

useContext Hooks, a function of the global data store, is a component of the data store that houses the parent component and can pass all types of child component data.

# useReducer Hooks

It works a bit like redux, data can be stored through these hooks and can be used by receiving this data in different components as required.

# useCallback Hooks

These hooks are used for optimization. These useCallback Hooks work so that components are not updated

# useMemo Hooks

These hooks are used for optimization. This useMemo Hooks works so that the components are not updated

# useRef Hooks

useRef Hooks works with the concept of creating references. That is, useRef Hooks works on all types of concepts in react components.

--

--

No responses yet