File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export default function Connector(store) {
1515
1616 let finalMapStateToTarget = mapStateToTarget || defaultMapStateToTarget ;
1717
18- const finalMapDispatchToTarget = isPlainObject ( mapDispatchToTarget ) ?
18+ const finalMapDispatchToTarget = isObject ( mapDispatchToTarget ) && ! isFunction ( mapDispatchToTarget ) ?
1919 wrapActionCreators ( mapDispatchToTarget ) :
2020 mapDispatchToTarget || defaultMapDispatchToTarget ;
2121
@@ -25,7 +25,7 @@ export default function Connector(store) {
2525 ) ;
2626
2727 invariant (
28- isPlainObject ( finalMapDispatchToTarget ) || isFunction ( finalMapDispatchToTarget ) ,
28+ isObject ( finalMapDispatchToTarget ) || isFunction ( finalMapDispatchToTarget ) ,
2929 'mapDispatchToTarget must be a plain Object or a Function. Instead received %s.' , finalMapDispatchToTarget
3030 ) ;
3131
Original file line number Diff line number Diff line change @@ -114,6 +114,16 @@ describe('Connector', () => {
114114 expect ( receivedDispatch ) . toBe ( store . dispatch ) ;
115115 } ) ;
116116
117+ it ( 'Should allow ES6 modules' , ( ) => {
118+ // The tests are run in Node, so we are unable to use actual ES6 modules. We get quite
119+ // close by emulating it
120+ class FakeModule {
121+ prop ( ) { }
122+ } ;
123+ const fakeModule = new FakeModule ( ) ;
124+ expect ( ( ) => connect ( ( ) => ( { } ) , fakeModule ) ( targetObj ) ) . toNotThrow ( ) ;
125+ } ) ;
126+
117127 it ( 'Should provide state slice, bound actions and previous state slice to target (function)' , ( ) => {
118128 const targetFunc = sinon . spy ( ) ;
119129
You can’t perform that action at this time.
0 commit comments