Skip to content

Add example to API docs for no-subscribe actions #331

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

Merged
merged 1 commit into from
Apr 2, 2016

Conversation

joshwcomeau
Copy link
Contributor

In a recent project, I needed a container component that had access to a few actions, but it didn't need to subscribe to the store. The component was just a button that performed an action; it didn't care about what the state of the app was.

The docs for connect don't have an example for how to omit the mapStateToProps argument, while still providing a value for mapDispatchToProps.

I'm not entirely sure if this is the best way to accomplish that goal, so please do let me know if there's a better/simpler way! I tried simply passing a single mapDispatchToProps argument, but it was interpreted as the mapStateToProps param.

@gaearon
Copy link
Contributor

gaearon commented Apr 2, 2016

We already have https://github.com/joshwcomeau/react-redux/blob/feature/injectActionsDocs/docs/api.md#inject-just-dispatch-and-dont-listen-to-store so maybe it’s worth putting the example next to it? Also let’s use null instead of false. Somehow that feels.. better.

@joshwcomeau joshwcomeau force-pushed the feature/injectActionsDocs branch from 9511865 to de36b15 Compare April 2, 2016 18:00
In a recent project, I needed a container component that had access
to a few actions, but it didn't need to subscribe to the store. The
component was just a button that performed an action; it didn't care
about what the state of the app was.

The docs for `connect` don't have an example for how to omit the
`mapStateToProps` argument, while still providing a value for
`mapDispatchToProps`.

I'm not entirely sure if this is the best way to accomplish that goal,
so please do let me know if there's a better/simpler way! I tried simply
passing a single `mapDispatchToProps` argument, but it was interpreted as
the `mapStateToProps` param.
@joshwcomeau joshwcomeau force-pushed the feature/injectActionsDocs branch from de36b15 to 2c05077 Compare April 2, 2016 18:02
@joshwcomeau
Copy link
Contributor Author

Yeah, I didn't wanna be presumptuous by putting my example so close to the top, but I agree it makes more sense there.

Since it then became the first example to use import * as actionCreators, I moved the parentheses explaining that bit to it.

@gaearon gaearon merged commit 2d5ee79 into reduxjs:master Apr 2, 2016
@gaearon
Copy link
Contributor

gaearon commented Apr 2, 2016

Even better. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants