UNPKG

react-redux-with-path

Version:

A version of react-redux designed for cases that want to access sub-tree of the state. and take it as state in mapStateToProps and mapDispatchToProps

29 lines (21 loc) 517 B
import { Component, PropTypes, Children } from 'react'; import pathType from '../utils/pathType'; export default class SubProvider extends Component { constructor(props, context) { super(props, context); this.path = props.path; } getChildContext() { return { path: this.path }; } render() { return Children.only(this.props.children); } } SubProvider.propTypes = { path: pathType, children: PropTypes.element.isRequired, }; SubProvider.childContextTypes = { path: pathType, };