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.
Multiplication (
multiply
): Define an action creator function namedmultiply
that generates an action object representing the multiplication operation. This action will contain the type'Multiply'
and theamount
to multiply the counter.Division (
divide
): Similarly, define an action creator function nameddivide
that generates an action object representing the division operation. This action will contain the type'Divide'
and theamount
to divide the counter.
Playground
Implement your solution in the following playground:
Get hands-on with 1400+ tech skills courses.