R
R
RomanSS2017-01-06 11:21:41
React
RomanSS, 2017-01-06 11:21:41

How to list multiple folders in react-route without creating new routes?

There is this route:

<Route path="test" component={Test1}>
  <Route path=":name" component={Name} />
</Route>
<Route path="*" component={NotFound} />

I don’t understand how to make it so that path=":name" skips only certain names, for example (name1, name2, name3), and the rest is thrown to NotFound. Do not list all possible routes.
<Route path="test" component={Test1}>
  <Route path="name1" component={Name} />
  <Route path="name2" component={Name} />
  <Route path="name3" component={Name} />
</Route>

How can I combine this in one route?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RubaXa, 2017-01-09
@RubaXa

Use onEnter .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question