UNPKG

react-tunnels

Version:

A easy way to communicate rendering logic and data to ancestor components in React.

28 lines (21 loc) 504 B
import PropTypes from 'prop-types' import { Children, Component } from 'react' import TunnelState from './TunnelState' class TunnelProvider extends Component { static propTypes = { children: PropTypes.node, } static childContextTypes = { tunnelState: PropTypes.object, } tunnelState = new TunnelState() getChildContext() { return { tunnelState: this.tunnelState, } } render() { return Children.only(this.props.children) } } export default TunnelProvider