如果您能指出错误,将不胜感激,我很疲惫。我正在使用这样的反应路由器:
<Router history={history}>
<div>
<Route exact path="/" component={SplashScreen} />
<Route path="/login" component={LoginComponent} />
</div>
</Router>
这工作得很好。然而,当我在 div 周围包裹另一个组件时,在这种情况下是一个StartupLogic
组件,路由停止工作具体我正在使用:
dispatch(push("/login"));
当StartupLogic
没有包裹在 div 周围时,这可以正常工作,这意味着 url 栏更改为localhost:3000/login
并且 LoginComponent 已安装。
当 StartupLogic 组件安装在 div 周围时,url 栏变为localhost:3000/login
但LoginComponent
不呈现,我被困在那里看着SplashScreen
.
StartupLogic 组件:
class AppDelegate extends Component {
componentDidMount(){
this.props.getX().then(allCountries => {
this.props.getY().then(res => {
setTimeout(() => {
console.log(this);
debugger;
this.forceUpdate();
},5000)
});
});
}
render() {
return (
<div>
{this.props.children}
</div>
);
}
}