connect-actions
v0.0.4
Published
Connect Redux actions by domain
Downloads
5
Maintainers
Readme
Connect Actions
Connect Redux actions by domain. Supports React & React Native.
Installation
npm i --save connect-actions
Usage
import connectActions from 'connect-actions';
import React, {Component, PropTypes} from 'react';
import * as NavigationActions from '../actions/navigation';
import * as UIActions from '../actions/ui';
import * as UserActions from '../actions/app';
@connectActions({NavigationActions, UIActions, UserActions})
class App extends Component {
static propTypes = {
NavigationActions: PropTypes.object.isRequired,
UIActions: PropTypes.object.isRequired,
UserActions: PropTypes.object.isRequired
};
componentWillMount() {
this.props.UserActions.fetchCurrentUser();
}
render() {
const {NavigationActions: {goHome}, UIActions: {showMenu}} = this.props;
return (
<div>
<button onClick={goHome}>Go Home</button>
<button onClick={showMenu}>Show Menu</button>
</div>
);
}
}
License
MIT