Reducers

Developed with
QA

The course is part of this learning path

ReactJS: Zero to Hero
course-steps
14
certification
7
lab-steps
3
description
1
play-arrow
Start course
Overview
DifficultyBeginner
Duration23m
Students50

Description

This module looks at how to manage state in React. You’ll be looking at state management, context, and reducers.  

Learning Objectives 

The objectives of this module are to provide you with an understanding of: 

  • State Management  
  • Context  
  • How to create and provide context  
  • Reducers  
  • How to provide dispatch 

Intended Audience  

This learning path is aimed at all who wish to learn how to use the ReactJS framework.  

Prerequisites

It is essential you understand the face of contemporary web development to attend this course. We insist upon JavaScript experience, along with good HTML and CSS skills. 

Feedback 

We welcome all feedback and suggestions - please contact us at qa.elearningadmin@qa.com to let us know what you think. 

Transcript

Now that we have abstracted state from components into context, we need to look further into how we can obtain initial values and update state. One strategy we can use here is to leverage the power of reducers. Reducers are not a concept that are exclusive to React. In fact, they're basically a JavaScript function. The idea of a reducer is that it takes the previous state and an action, and returns a brand new state based on these arguments. There are two basic principles for using reducers, but they're a good line to follow wherever you may use state. The first is that state should never be mutated; it should always be reset! Even if the state is the same. The second principle is that the previous state can be used as part of the new state by using JavaScript's spread up operator. If you aren't familiar with the spread operator, I suggest you pause the video and go look it up. To use reducer, you need to be able to dispatch actions from components in the app, recognize that that has happened, and then be able to respond to them appropriately.

Lectures

Introduction to State Management - Context - How to Create and Provide Context - Consume Context - Actions in Reducers - The useReducer Hook - Providing Dispatch

About the Author
Students3156
Labs8
Courses29
Learning paths6

An outstanding trainer in software development with more than 15 years experience as a Corporate and Apprentice Trainer, ICT Teacher and Head of Department, with a passion for technology and its uses. Continuing to develop existing and new skills and courses, primarily in web design using PHP, JavaScript, HTML, CSS and SQL but also OOP (Java), programming foundations (Using Python), DevOps (Git, CI/CD, etc) and Agile/Scrum. Practically minded, a quick learner and a problem solver with an attention to detail to ensure high quality outcomes.

Covered Topics