Skip to content

Add <Redirect/> component #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ryanflorence opened this issue Aug 1, 2014 · 5 comments · Fixed by #172
Closed

Add <Redirect/> component #159

ryanflorence opened this issue Aug 1, 2014 · 5 comments · Fixed by #172

Comments

@ryanflorence
Copy link
Member

I've been thinking about this for a while, and I like it.

  • URLs in an app change
  • sometimes you want to defend against users deleting segments of a URL
<Routes>
  <Route name="dashboard" handler={Dashboard}/>
  <!-- we used to have `/home` but now we want `dashboard` -->
  <Redirect path="home" to="dashboard"/>

  <Route handler={User}>
    <Route name="user-details" path="user/:userId/details" handler={Details}/>
    <Route name="user-activity" path="user/:userId/activity" handler={Activity}/>
    <!-- guard against users deleting the `details` or `activity` segments of the url -->
    <Redirect path="user/:userId" to="user-activity"/>
  </Route>
</Routes>

This prevents devs from having to write a bunch of redirect code in handlers that don't need to exist. Maybe opens up some convention for us in server rendering to tell the dev to send the proper status code.
#149 is kindof related

@mjackson
Copy link
Member

mjackson commented Aug 1, 2014

I'm 👍 on this. Should be fairly easy to implement given the current API as well. We already have transition.redirect().

@ryanflorence
Copy link
Member Author

great opportunity to make RouteMixin too I think

@mjackson
Copy link
Member

mjackson commented Aug 1, 2014

Yeah, but I'd prefer to stay away from naming stuff *Mixin. The mixin name should describe what it does, not what it is.

@ryanflorence
Copy link
Member Author

yessir, I prefer the -able variants. Routable

@ryanflorence
Copy link
Member Author

closed, follow #172 for updates

ryanflorence added a commit that referenced this issue Aug 6, 2014
jakobz pushed a commit to jakobz/react-router that referenced this issue Aug 7, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jan 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants