react-router icon indicating copy to clipboard operation
react-router copied to clipboard

nested Redirect throws error

Open maxhoffmann opened this issue 11 years ago • 2 comments

Having a Redirect in my routes setup like this:

<Route name="accounts" handler={Accounts}>
  <Route path=":account" name="account" handler={Account}>
    <Route name="profile" handler={Profile} />
    <Redirect path="/accounts/:account" to="profile" />
  </Route>
</Route>

react-router throws this error in version >= 0.12.1:

Error: Invariant Violation: You cannot nest path "/accounts/:account" inside "/accounts/:account

There is no error using version 0.12.0 though. Is this a bug or did you change the API?

maxhoffmann avatar Mar 01 '15 18:03 maxhoffmann

Not sure if that's intentional or not.

Your scenario looks a lot like the one in #883 though.

agundermann avatar Mar 02 '15 19:03 agundermann

yep, I just do this https://github.com/rackt/react-router/issues/883#issuecomment-76299927

I would merge a <DefaultRedirect/> though.

ryanflorence avatar Mar 25 '15 18:03 ryanflorence