Skip to content
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

<Link to> with relative link broken? #3085

Closed
Pomax opened this issue Feb 16, 2016 · 5 comments
Closed

<Link to> with relative link broken? #3085

Pomax opened this issue Feb 16, 2016 · 5 comments

Comments

@Pomax
Copy link

Pomax commented Feb 16, 2016

I have a router set up as

<Router>
    <Route path='/' component={Root}>
...
      <Route path='section1' component={require('../pages/section1.jsx')}>
        <Route path='details' component={require('../pages/section-details.jsx')} />
      </Route>
...
    </Route>
</Router>

and in the section1.jsx have a <Link to='./details/'>details</Link>, but this doesn't resolve correctly at all. The browser shows a link that "should" go to .../section/details according to the browser status bar, but clicking it results in a react-router error instead:

Warning: [react-router] Location "./details/" did not match any routes

If I turn this <Link> into an <a> things work find but of course then I lose all the benefits of navigation inspection etc.

https://github.com/reactjs/react-router/blob/latest/docs/API.md#link does not say anything about relative links being broken, so: is this a bug, or is this intended? And if intended, what's the proper way to get a <Link> going to a relative path?

@timdorr
Copy link
Member

timdorr commented Feb 16, 2016

Relative <Link>s aren't supported yet. Watch #2172.

@timdorr timdorr closed this as completed Feb 16, 2016
@Pomax
Copy link
Author

Pomax commented Feb 16, 2016

Now watching (but it does look like that issue died about a month ago rather than being on track).

Can we at least reopen this issue and make its closing contingent on the API docs being appended with a note that <Link> cannot currently do relative links, with some code that shows how someone can build the absolute path using whatever contexts are available in a component in the mean time?

Given that URLs are the backbone of the web, it's pretty important to let people know that <Link> does not currently work as new users will expect it to.

@timdorr
Copy link
Member

timdorr commented Feb 16, 2016

It's not dead. We were waiting on some API changes with 2.0 so that we can work on it.

@timdorr
Copy link
Member

timdorr commented Feb 16, 2016

Check #2933 if you have some documentation improvements. PRs are the best way to get it solved! 😄

@Pomax
Copy link
Author

Pomax commented Feb 16, 2016

They most certainly are! But I clearly don't know as much about <Link> as people active on this project, so the best people to write that doc improvement is in this case not-me, but someone who knows the state of <Link> =)

I don't even know what code to write to get an current absolute path so I can even work around this issue. Is there some documentation or an issue that already explains that? (that was part two of my issue, really. How do I use Link if I can't do relative links? The docs don't seem to explain this anywhere and I don't see any stackoverflow questions on it either, especially with 2.0.0 being so recent)

@lock lock bot locked as resolved and limited conversation to collaborators Jan 22, 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

No branches or pull requests

2 participants