0

Can can't find the problem here it might be a typo but I think I have followed the documentation..

index.js:

ReactDOM.render(
  <Router history={hashHistory}>
    <Route path="/" component={App}></Route>
    <Route path="/match:id" component={MatchFeedComponent}></Route>
    <Route path="/user" component={UserPageComponent}></Route>
    <Route path="/comments" component={CommentHolderComponent}></Route>
    <Route path="/post-talk" component={AddTalkComponent}></Route>
    <Route path="/add-match" component={AddMatchComponent}></Route>
  </Router>,
  document.getElementById('app')
);

In my

<Link to={{ pathname:"/match/", query: {id: this.id}}}>

I get: [react-router] Location "/match/?id=-KXKIhpF8mdWDn9C5Tnd" did not match any routes

It works fine without any params but can't find it now.

2 Answers 2

2

If you want "id" to be a query string param, it shouldn't appear in your route. Change to this:

<Route path="/match" component={MatchFeedComponent}></Route>

...and then just pick up the id from props.location.query inside your component

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

Comments

2

React Router usually doesn't work with the "regular queries", at least how you've set it up. Your Router expects something like /match/-KXKIhpF8mdWDn9C5Tnd instead of /match/?id=-KXKIhpF8mdWDn9C5Tnd. Try this as your Link:

<Link to={`/match/${this.id}`}>

and then change your route to:

<Route path="/match/:id" component={MatchFeedComponent}></Route>

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.