Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function Connector(store) {

let finalMapStateToTarget = mapStateToTarget || defaultMapStateToTarget;

const finalMapDispatchToTarget = isPlainObject(mapDispatchToTarget) ?
const finalMapDispatchToTarget = isObject(mapDispatchToTarget) && !isFunction(mapDispatchToTarget) ?
wrapActionCreators(mapDispatchToTarget) :
mapDispatchToTarget || defaultMapDispatchToTarget;

Expand All @@ -25,7 +25,7 @@ export default function Connector(store) {
);

invariant(
isPlainObject(finalMapDispatchToTarget) || isFunction(finalMapDispatchToTarget),
isObject(finalMapDispatchToTarget) || isFunction(finalMapDispatchToTarget),
'mapDispatchToTarget must be a plain Object or a Function. Instead received %s.', finalMapDispatchToTarget
);

Expand Down
10 changes: 10 additions & 0 deletions test/components/connector.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ describe('Connector', () => {
expect(receivedDispatch).toBe(store.dispatch);
});

it('Should allow ES6 modules', () => {
// The tests are run in Node, so we are unable to use actual ES6 modules. We get quite
// close by emulating it
class FakeModule {
prop() {}
};
const fakeModule = new FakeModule();
expect(() => connect(() => ({}), fakeModule)(targetObj)).toNotThrow();
});

it('Should provide state slice, bound actions and previous state slice to target (function)', () => {
const targetFunc = sinon.spy();

Expand Down