diff --git a/src/bindActionCreators.js b/src/bindActionCreators.js index 9b0cc061eb..da650d3b57 100644 --- a/src/bindActionCreators.js +++ b/src/bindActionCreators.js @@ -1,5 +1,5 @@ function bindActionCreator(actionCreator, dispatch) { - return (...args) => dispatch(actionCreator(...args)) + return function() { return dispatch(actionCreator.apply(this, arguments)) } } /** diff --git a/test/bindActionCreators.spec.js b/test/bindActionCreators.spec.js index f4a8cb2b44..7c8a517c96 100644 --- a/test/bindActionCreators.spec.js +++ b/test/bindActionCreators.spec.js @@ -33,6 +33,21 @@ describe('bindActionCreators', () => { ]) }) + it('wraps action creators transparently', () => { + const uniqueThis = {} + const argArray = [1, 2, 3] + function actionCreator() { + return { type: 'UNKNOWN_ACTION', this: this, args: [...arguments] } + } + const boundActionCreator = bindActionCreators(actionCreator, store.dispatch) + + const boundAction = boundActionCreator.apply(uniqueThis,argArray) + const action = actionCreator.apply(uniqueThis,argArray) + expect(boundAction).toEqual(action) + expect(boundAction.this).toBe(uniqueThis) + expect(action.this).toBe(uniqueThis) + }) + it('skips non-function values in the passed object', () => { const boundActionCreators = bindActionCreators({ ...actionCreators,