Почему это не работает?
<Provider store={ store }>
<BrowserRouter>
<Switch>
{routes && routes.map(
(config, i) => <PrivateRoute key={ `route-render-${ i }` } config={ config } />
)}
</Switch>
</BrowserRouter>
</Provider>
Но если я изменил PrivateRoute
на Route
, содержимое компонента будет работать так, как ожидается.
Вот мой PrivateRoute.js
import React, { Component } from 'react'
import { Route } from 'react-router-dom'
class PrivateRoute extends Component {
render() {
const { config: { access, roles, ...rest } } = this.props
return (
<Route { ...rest } />
)
}
}
export default PrivateRoute
Вот routes
выглядит как
import * as shared from '../modules/shared/pages'
export const routes = [
{
path: '/',
roles: [],
access: [],
exact: true,
name: 'Login',
component: shared.Login
},
{
name: 'PageNotFound',
component: shared.PageNotFound
}
]