0.0.2 • Published 10 years ago

react-redux-connect-context v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

React Redux Connect Context

Enhanced version of redux' connect, that puts all action creators into the child context of the component.

Example

import React, {Component, PropTypes} from 'react';
import {bindActionCreators} from 'redux';

import connectContext from 'react-redux-connect-context';

function click() {
  return {
    type: 'CLICK',
  }
}

function mapStateToProps(state) {
  return state;
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({click}, dispatch);
}

@connectContext(mapStateToProps, mapDispatchToProps)
class Parent extends Component {
  render() {
    return <Child />;
  }
}

class Child extends Component {
  contextTypes: {
    click: PropTypes.func,
  }

  render() {
    <button onClick={this.context.click}/>
  }
}
0.0.2

10 years ago

0.0.1

10 years ago