Skip to content

Commit 8bb94c7

Browse files
committed
Merge pull request #295 from jhewlett/breaking-changes-1.0
Allow es6 symbols to be used as action types
2 parents af474ba + adbfbdd commit 8bb94c7

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/utils/combineReducers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ActionTypes } from '../createStore';
55

66
function getErrorMessage(key, action) {
77
var actionType = action && action.type;
8-
var actionName = actionType && `"${actionType}"` || 'an action';
8+
var actionName = actionType && `"${actionType.toString()}"` || 'an action';
99

1010
return (
1111
`Reducer "${key}" returned undefined handling ${actionName}. ` +

test/utils/combineReducers.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,23 @@ describe('Utils', () => {
8383
);
8484
});
8585

86+
it('should allow a symbol to be used as an action type', () => {
87+
const increment = Symbol('INCREMENT');
88+
89+
const reducer = combineReducers({
90+
counter(state = 0, action) {
91+
switch (action.type) {
92+
case increment:
93+
return state + 1;
94+
default:
95+
return state;
96+
}
97+
}
98+
});
99+
100+
expect(reducer(0, {type: increment}).counter).toEqual(1);
101+
});
102+
86103
it('should throw an error if a reducer attempts to handle a private action', () => {
87104
expect(() => combineReducers({
88105
counter(state, action) {

0 commit comments

Comments
 (0)