@IIITRIX

Как изменить Router?

Хочу привести роуты к такому виду
const routes = [
  {
    path: "/",
    exact: true,
    component: Home
  },
  {
    path: "/news",
    component: News
  }
];

Сейчас у меня так
const App = ({ location }) => (
<Switch>
 <Route
   location={location}
   exact
   path="/"
   render={() => (<Articles documentTitleID="popular_articles_page.title" />)}
  />
</Switch>
)


Вопрос, как отобразить render с видом роутов в варианте 1
  • Вопрос задан
  • 60 просмотров
Решения вопроса 1
tsepen
@tsepen
Frontend developer
{
routes.map(item => (
 <Route
  key={item.path}
   exact={item.exact}
   path={item.path}
   component={item.component}
  />
))
}
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы