У меня есть дочерние маршруты, и когда я пытаюсь изменить маршруты в AppMain.js, он изменяет URL-адрес, но компонент не обрабатывается, вместо этого существующий компонент повторно визуализируется. Но если я делаю то же самое history.push внутри Dashboard
или BatteryTable
, маршрут работает нормально.
App.js
<Router>
<Route exact path="/" component={withRouter(Auth)} />
<Route path="/main" component={withRouter(AppMain)} />
</Router>
AppMain.js
constructor(props) {
super(props)
this.props.history.push('/main/dashboard')
}
render() {
return(
<Routes match={match} />
)
}
Routes.js
<Router>
<Switch>
<Route path={`${this.props.match.path}/dashboard`} component={withRouter(Dashboard)} />
<Route path={`${this.props.match.path}/batterytable`} component={withRouter(BatteryTable)} />
</Switch>
</Router>