Challenge: Simplifying Reducers in React

Test your understanding of the React reducers.

We'll cover the following

Task

Expand the TypeScript example explored in this chapter by adding two more actions for the CounterReducer: multiplication and division.

  1. Multiplication (multiply): Define an action creator function named multiply that generates an action object representing the multiplication operation. This action will contain the type 'Multiply' and the amount to multiply the counter.

  2. Division (divide): Similarly, define an action creator function named divide that generates an action object representing the division operation. This action will contain the type 'Divide' and the amount to divide the counter.

Playground

Implement your solution in the following playground:

Get hands-on with 1400+ tech skills courses.