I
I
IIITRIX2019-02-21 14:01:27
React
IIITRIX, 2019-02-21 14:01:27

How to change Router?

I want to bring the routes to this form

const routes = [
  {
    path: "/",
    exact: true,
    component: Home
  },
  {
    path: "/news",
    component: News
  }
];

Now I have this
const App = ({ location }) => (
<Switch>
 <Route
   location={location}
   exact
   path="/"
   render={() => (<Articles documentTitleID="popular_articles_page.title" />)}
  />
</Switch>
)

The question is how to display render with the view of routes in option 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Okhotnikov, 2019-02-21
@IIITRIX

{
routes.map(item => (
 <Route
  key={item.path}
   exact={item.exact}
   path={item.path}
   component={item.component}
  />
))
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question