Nihal Parmar
2 min readApr 5, 2022

--

An Easy Way to Understanding React useReducer Hook

Hi Everone, this is my 1st Article regarding React Hooks. Here I am going to explain a very important and useful topic: React Hooks. This will be a brief explanation about useReducer Hook.

1st question will come to our mind … What is the useReducer hook?

useReducer is usually preferable useState when you have complex state logic that involves multiple sub-values or when the next state depends on the previous one. useReducer also lets you optimize performance for components that trigger deep updates because you can pass dispatch them down instead of callback.

In the code snippet, we have

  • first defined an initial state for our component
  • added a reducer function that updates that state depending on the action dispatched and,
  • we have finally initialized the state for our component.

If you have any suggestions so please suggest me so I will try to use them in my next article.

Follow me for new tidbits on the domain of tech.

Have a look at my Portfolio : https://nihalparmarportfolio.web.app/

--

--

Nihal Parmar

Software Engineer @Crest Data System|| 6⭐ @HackerRank || Tech-Enthusiast || GSSoC’21 || Full Stack Developer