Skip to content
Closed
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
5 changes: 5 additions & 0 deletions src/components/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
const version = nextVersion++

return function wrapWithConnect(WrappedComponent) {
invariant(
typeof WrappedComponent == 'function',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: ===?

`You must pass a component to the function returned by ` +
`connect. Instead received ${WrappedComponent}`
)
const connectDisplayName = `Connect(${getDisplayName(WrappedComponent)})`

function checkStateShape(props, methodName) {
Expand Down
6 changes: 6 additions & 0 deletions test/components/connect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,12 @@ describe('React', () => {
expect(stub.props.passVal).toBe('otherval')
})

it('should throw an error if a component is not passed to the function returned by connect', () => {
expect(connect()).toThrow(
/You must pass a component to the function/
)
})

it('should throw an error if mapState, mapDispatch, or mergeProps returns anything but a plain object', () => {
const store = createStore(() => ({}))

Expand Down