Skip to content

Instantly share code, notes, and snippets.

@sarjumulmi
Created March 22, 2018 20:21
Show Gist options
  • Save sarjumulmi/ee269f04eb7ba9d71ccc5fd30127821c to your computer and use it in GitHub Desktop.
Save sarjumulmi/ee269f04eb7ba9d71ccc5fd30127821c to your computer and use it in GitHub Desktop.
import React, {Component} from "react";
import PropTypes from "prop-types";
export default class Provider extends Component {
const {dispatch, subscribe, getState} = this.props.store;
getChildContext(){
return {dispatch, subscribe, getState};
}
return (
<div>{this.props.children}</div>
)
}
Provider.propTypes = {
children: PropTypes.any,
store: PropTypes.shape({
dispatch: PropTypes.func,
subscribe: : PropTypes.func,
getState: : PropTypes.func
})
}
Provider.childContextTypes = {
dispatch: PropTypes.func,
subscribe: : PropTypes.func,
getState: : PropTypes.func
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment