import React from 'react';
import PropTypes from 'prop-types';
class Provider extends React.Component {
static childContextTypes = {
store:PropsTypes.object
}
constructor(props,context){
super(props,context)
this.store=props.store
}
getChildContext(){
return {store:this.store}
}
render(){
return this.props.children
}
}
Provider的作用是把store放在context里面,所有的子元素可以直接提取到store