Provider
2024-09-04 01:06:09
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
最新文章
- 一道js面试题
- Windows Squid 安装配置
- C/C++中的getline函数总结:
- spring支持的websocket
- c语言知识(1)
- awr报告
- HTML5简介、视频
- ios app唤起页面跳转
- Python学习-使用matplotlib画动态多图
- android项目红色感叹号
- bzoj 2004: [Hnoi2010]Bus 公交线路
- 读spring源码(三)-ClassPathXmlApplicationContext-getBean
- class中限定绑定属性__slots__方法
- appium定位之xpath定位
- 【CSS基础】实现 div 里的内容垂直水平居中
- 利用Nuget打包添加tools下intsall.ps1【powershell脚本】修改.csproj文件
- MVC 学习(一)Linq to Entities 简单Demo
- poj 3013 最短路变形
- Hibernate 查询sql结果行数的几种方法
- 推荐一款基于Angular实现的企业级中后台前端/设计解决方案脚手架