0

How do you get nested routing with react-router-redux (5.0.0-alpha.9)?

I want to be able to route to the likes of /event/create I am able to successfully get to a route of /event/:id, e.g. /event/1234

I have -

<Route exact path="/" component={HomePage} />
<Route path="/event/:id" component={EventView} />
<Route path="/event/create" component={EventCreate} />

It looks as though when I go to /event/create is routing to /event/:id

1

1 Answer 1

3

The Router will return on the first match. In your case, you simply need to move the last two statements as :id will match on anything:

<Route exact path="/" component={HomePage} />
<Route path="/event/create" component={EventCreate} />
<Route path="/event/:id" component={EventView} />

This will match on /event/create first and if there's any other value, it will match on the subsequent route.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.