3

Given this React router configuration:

<Router history={browserHistory}>
    <Route path="/farm/:type?period=:period" component={Farm} />
    <Route path="/pen/:penId" component={Pen} />
    <Route path="/pen/:penId/cow/:cowId" component={Cow} />
    <Route path="*" component={Farm} />
</Router>

Why is http://localhost:8080/farm/average?period=day only matching the catch-all route and not the first one?

1 Answer 1

2

Query string parameters don't need to be included in the <Route> definition.

Changing the route definition to <Route path="/farm/:type" component={Farm} /> solved the problem.

Query string parameters are still available under props.location.query

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.