Created
July 11, 2017 19:24
-
-
Save hkjpotato/d4466c8476218850568d639422f809ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PropTypes } from 'react' | |
const storeShape = PropTypes.shape({ | |
subscribe: PropTypes.func.isRequired, | |
dispatch: PropTypes.func.isRequired, | |
getState: PropTypes.func.isRequired | |
}) | |
const subscriptionShape = PropTypes.shape({ | |
trySubscribe: PropTypes.func.isRequired, | |
notifyNestedSubs: PropTypes.func.isRequired | |
}) | |
class Provider extends React.Component { | |
constructor(props, context) { | |
super(props, context) | |
this.store = props.store; | |
} | |
getChildContext() { | |
return { store: this.store, parentSub: null } | |
} | |
render() { | |
return React.Children.only(this.props.children) | |
} | |
} | |
Provider.childContextTypes = { | |
store: storeShape, | |
parentSub: subscriptionShape, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment