Skip to content
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

Send actions from React component #34

Closed
conradz opened this issue Feb 17, 2015 · 3 comments
Closed

Send actions from React component #34

conradz opened this issue Feb 17, 2015 · 3 comments

Comments

@conradz
Copy link
Contributor

conradz commented Feb 17, 2015

I'm missing one big part of how this all works: how do I dispatch an action from an event handler in a React component? I don't see that ReactMixin or ReactComponent have methods for doing this. I could get the flux instance from context and dispatch actions there, but that seems very messy.

@acdlite
Copy link
Owner

acdlite commented Feb 17, 2015

With FluxMixin, flux is accessible as this.flux, so you can do this:

this.flux.getActions('actions').someAction();

With FluxComponent, flux is a prop of the child:

this.props.flux.getActions('actions').someAction();

How would you prefer for this to work?

@conradz
Copy link
Contributor Author

conradz commented Feb 17, 2015

OK, that makes sense. I didn't realize that I could use FluxComponent/FluxMixin to get the flux instance (it doesn't seem that it's documented for the FluxMixin).

@conradz conradz closed this as completed Feb 17, 2015
@acdlite
Copy link
Owner

acdlite commented Feb 17, 2015

@conradz It is, just poorly I guess. I will update the docs to make them more clear. 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

No branches or pull requests

2 participants