-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support passing store in via props for testing #44
Conversation
@@ -72,7 +72,7 @@ export default function createConnect(React) { | |||
static WrappedComponent = WrappedComponent; | |||
|
|||
static contextTypes = { | |||
store: storeShape.isRequired | |||
store: storeShape | |||
}; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add similar propTypes
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
this.dispatchProps = computeDispatchProps(context); | ||
this.store = props.store || context.store; | ||
|
||
invariant(this.store, '`store` must be passed in via the context or props'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change it to
Could not find "store" in either context or props of "${this.constructor.displayName}". Either wrap the root component in a , or explicitly pass "store" as a prop to "${this.constructor.displayName}".
and also verify that the error message is correct in a unit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated with test.
Thank you for your work on this. Released in |
Allow you to pass the redux store in via props to make it easier to unit test (Instead of having to mess with
Provider
's or contexts)See also #38
Closes #33