May 2019
Intermediate to advanced
496 pages
10h 38m
English
Before we begin building the reducer, let's think about what we're going to build.
The reducer will be a higher-order function which, when called with an existing reducer, returns a new reducer that returns the state we're expecting. In our production code, we'll replace this store code:
combineReducers({ script: scriptReducer})
With this "decorated" reducer, which takes exactly the same reducer and wraps it in the withUndoRedo reducer that we'll build in this section:
combineReducers({ script: withUndoRedo(scriptReducer)})
To test this, we'll need to use a spy to act in place of the script reducer, which we'll call the decoratedReducerSpy.
Read now
Unlock full access