Skip to content

Commit a6d82f0

Browse files
committed
Add code + test for #436
1 parent e907f85 commit a6d82f0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/components/connectAdvanced.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ export default function connectAdvanced(
6464
}
6565

6666
return function wrapWithConnect(WrappedComponent) {
67+
invariant(
68+
typeof WrappedComponent == 'function',
69+
`You must pass a component to the function returned by ` +
70+
`connect. Instead received ${WrappedComponent}`
71+
)
72+
6773
const wrappedComponentName = WrappedComponent.displayName
6874
|| WrappedComponent.name
6975
|| 'Component'

test/components/connect.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,12 @@ describe('React', () => {
10171017
expect(stub.props.passVal).toBe('otherval')
10181018
})
10191019

1020+
it('should throw an error if a component is not passed to the function returned by connect', () => {
1021+
expect(connect()).toThrow(
1022+
/You must pass a component to the function/
1023+
)
1024+
})
1025+
10201026
it('should throw an error if mapState, mapDispatch, or mergeProps returns anything but a plain object', () => {
10211027
const store = createStore(() => ({}))
10221028

0 commit comments

Comments
 (0)