Skip to content

useReducer is one out of fifteen (15) react built in hooks it helps in managing multiple states that relates to each other an example would be making an api request or handling multiple form fields

Notifications You must be signed in to change notification settings

okeresamuel/The-useReducer-Hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The-useReducer-Hook

useReducer is one out of fifteen (15) built in react hooks. it helps in managing multiple states that relates to each other example would making an api request or handling multiple form fields

There are many different hooks in react let's look at the useReducer

The function of the useReducer hook is based on managing multiple states that are related to each other

some examples and use cases are managing multiple form inputs or making an API request

The useState hook is similar to the useReducer hook But the differences are,

The useState hook can be used to manage one or two states but when there are multiple states, creating so many useState hooks can get messy.

Its a good idea to use the useReducer hook to manage multiple states and as well improve readability (dry) ☀️

*** The code show how to use the useReducer hook to manage multiple states in this case we are making an api request to fetch user informations from an external database.

Screenshot (25)

Read more: https://medium.com/@okeresamuel360/the-usereducer-hook-in-react-5b3a4af93af5

About

useReducer is one out of fifteen (15) react built in hooks it helps in managing multiple states that relates to each other an example would be making an api request or handling multiple form fields

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published