Skip to content
This repository was archived by the owner on Dec 9, 2021. It is now read-only.

Commit edb9dab

Browse files
author
Robert S
committed
add comments
1 parent 65991fd commit edb9dab

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/stores/rootReducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { combineReducers } from 'redux';
22
import { connectRouter } from 'connected-react-router';
3-
import ShowsReducer from './shows/ShowsReducer';
43
import RequestingReducer from './requesting/RequestingReducer';
54
import ErrorReducer from './error/ErrorReducer';
5+
import ShowsReducer from './shows/ShowsReducer';
66

77
export default (history) => {
88
const reducerMap = {

src/utilities/BaseReducer.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ export default class BaseReducer {
22
initialState = {};
33

44
reducer = (state = this.initialState, action) => {
5-
const handler = this[action.type];
5+
// if the action type is used for a method name then this be a reference to
6+
// that class method.
7+
// if the action type is not found then the "method" const will be undefined.
8+
const method = this[action.type];
69

7-
if (!handler || action.error) {
10+
// if the action type "method" const is undefined or the action is an error
11+
// return the state.
12+
if (!method || action.error) {
813
return state;
914
}
1015

11-
return handler(state, action);
16+
// Return the modified state from the method.
17+
return method(state, action);
1218
};
1319
}

0 commit comments

Comments
 (0)