Skip to content

Instantly share code, notes, and snippets.

@zedd45
Last active November 28, 2016 20:05
Show Gist options
  • Save zedd45/0eaabdcafdfb5f1fef8560c37e3208a3 to your computer and use it in GitHub Desktop.
Save zedd45/0eaabdcafdfb5f1fef8560c37e3208a3 to your computer and use it in GitHub Desktop.
What we have here, is a failure to communicate

If you ever get errors about wrapWithConnect taking a null or undefined component, it’s because you forgot to wrap the component.

Here's the error message I got, for convienence / reference:

wrapWithConnect(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

wrong:

export default connect(mapStateToProps);

correct:

export default connect(mapStateToProps)(MyComponent);

the error is ambiguous if you come back from a long break (holiday, weekend) because it does not tell you the name of the component that’s causing the problem because it does not know what you didn’t pass.

Further compounding the problem, I supplied an ES6 arrow function as the first argument to connect (aka using an IIFE for mapStateToProps)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment