connect-actions

Connect Redux actions by domain

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
connect-actions
000.0.47 years ago7 years agoMinified + gzip package size for connect-actions in KB

Readme

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