Skip to content

inherit paths from parent routes #244

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 29, 2014 · 8 comments
Closed

inherit paths from parent routes #244

ryanflorence opened this issue Aug 29, 2014 · 8 comments

Comments

@ryanflorence
Copy link
Member

With the introduction of DefaultRoute and NotFoundRoute I think we need to start inheriting the parent routes.

Both of these new components inherit their parent route in one way or another. As I've been writing the docs and coming up with examples it now feels awkward that normal routes don't get their parent's route. It makes the route config less intuitive than I think it could be.

My proposal is simple and follows HTML precedent:

  1. paths that start with / are absolute and work the way they do today
  2. all others are relative
  3. assumed paths from names would be relative, duplicates should throw (maybe we would already)

A potential route config would look like:

<Routes location="history">
  <Route name="courses" handler={Courses}>
    <!-- note the absolute path for course -->
    <Route name="course" path="/course/:courseId" handler={Course}>
      <!-- full path is `/course/:courseId/announcements`, inherits parent -->
      <Route name="announcements" handler={Announcements} />
      <!-- full path is `/course/:courseId`, inherits parent -->
      <DefaultRoute handler={CourseDashboard} />
      <!-- full path is `/course/:courseId/*`, inherits parent -->
      <NotFoundRoute handler={CoursePathNotFound} />
    </Route>
  </Route>
</Routes>

So ... yeah ... If <Route/> can't inherit the parent, it makes understanding the relationship that DefaultRoute and NotFoundRoute have with the parent more difficult, its also pretty convenient and what you want most of the time.

@mjackson
Copy link
Member

Ya. I think I'm in agreement here. 🐬

@ryanflorence
Copy link
Member Author

I've almost got a branch ready

@ryanflorence
Copy link
Member Author

I just realized it also gives meaning to nested <Redirect/>s

@mjackson
Copy link
Member

uhoh. I'm working in the exact same portion of the code right now. Trying to make it possible for <DefaultRoute> to have a name prop.

ryanflorence added a commit that referenced this issue Aug 29, 2014
- paths that start with `/` are absolute like they
  used to be

- paths that don't start with `/` are now relative
  (meaning they inherit their parent path)

- assumed `path`s from `name`s are relative

closes #244
@ryanflorence
Copy link
Member Author

they don't need a name, you redirect/transition/link to the parent.

@mjackson
Copy link
Member

There's a small conflict. I'll fix it.

@mjackson
Copy link
Member

you redirect/transition/link to the parent.

That's what I thought too, but it feels counterintuitive.

@nishp1
Copy link
Contributor

nishp1 commented Sep 12, 2014

Thanks for this. Love it.

@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.

3 participants