🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEreact

react Documentation

LOADING ENGINE...

React Reducers

Master React components, hooks, and best practices.

Reducers

Author

Pascual Vila

Frontend Instructor.

Reducers are pure functions that take the current state and an action, and return a new state. They are the key piece in Redux for updating the application's state.

Example of a reducer:

          {`function counter(state = 0, action) {
            switch (action.type) {
              case "INCREMENT":
                return state + 1;
              case "DECREMENT":
                return state - 1;
              default:
                return state;
            }
          }`}