Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs React视图未使用redux更新_Reactjs_View_Redux_Jsx - Fatal编程技术网

Reactjs React视图未使用redux更新

Reactjs React视图未使用redux更新,reactjs,view,redux,jsx,Reactjs,View,Redux,Jsx,react视图未更新(从未调用渲染),但已调用reducer 我有以下资料: 1) 。react视图:如果需要显示“TodoList”或“HousingInfo”,我将在根状态下创建一个字段,以确定是否需要显示“TodoList”或“HousingInfo” 导出默认类RightPane扩展React.Component{ 静态上下文类型={ 存储:React.PropTypes.object } render(){ let store=this.context.store; 让curPage=

react视图未更新(从未调用渲染),但已调用reducer

我有以下资料:

1) 。react视图:如果需要显示“TodoList”或“HousingInfo”,我将在根状态下创建一个字段,以确定是否需要显示“TodoList”或“HousingInfo”

导出默认类RightPane扩展React.Component{
静态上下文类型={
存储:React.PropTypes.object
}
render(){
let store=this.context.store;
让curPage=store.getState()[“mainRightPanePage”].currentPage;
返回(
{(store.getState()[“mainRightPanePage”].currentPage===“TodoList”)&&}
{(store.getState()[“mainRightPanePage”].currentPage===“HousingInfo”)&&}
)
}
}

2) 。另一个组件中的操作调度

导出默认类LeftPane扩展React.Component{
静态上下文类型={
存储:React.PropTypes.object
}
handleink(页面ID,e){
e、 预防默认值();
let store=this.context.store;
dispatch({'type':'switchPage','pageId':pageId});
...
}
3) 。减速器:调用了以下减速器

const mainRightPanePage=(状态={'currentPage':'TodoList'},操作)=>{
开关(动作类型){
案例“切换页面”:
返回Object.assign({},state{
当前页面:action.pageId
})
违约:
返回状态
}
}
导出默认mainRightPanePage
我错过了什么


谢谢

在您的示例中,
右窗格
组件不知道Redux状态已更新,因为您尚未订阅Redux状态更改。您可以使用方法直接订阅Redux存储,也可以使用
React Redux
中的方法将组件连接到Redux存储(推荐):

从'react redux'导入{connect};
...
类RightPane扩展了React.Component{
...
render(){
让currentPage=this.props.currentPage;
返回(
{(currentPage==“TodoList”)&&}
{(当前页面===“住房信息”)&&}
)
}
}
常量mapStateToProps=(状态)=>{
返回{
currentPage:state.mainRightPanePage.currentPage
}
};
导出默认连接(
mapStateToProps
)(右窗格);

在您的示例中,
右窗格
组件不知道Redux状态已更新,因为您尚未订阅Redux状态更改。您可以使用方法直接订阅Redux存储,也可以使用
React Redux
中的方法将组件连接到Redux存储(推荐):

从'react redux'导入{connect};
...
类RightPane扩展了React.Component{
...
render(){
让currentPage=this.props.currentPage;
返回(
{(currentPage==“TodoList”)&&}
{(当前页面===“住房信息”)&&}
)
}
}
常量mapStateToProps=(状态)=>{
返回{
currentPage:state.mainRightPanePage.currentPage
}
};
导出默认连接(
mapStateToProps
)(右窗格);

您在哪里使用了
store.subscribe()
?或者您可以使用
react redux
将存储数据连接到组件您在哪里使用了
store.subscribe()
?或者您可以使用
react redux
将存储数据连接到组件