Skip to content

Relative <Link/>s not working in v4 #3901

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
vkbansal opened this issue Sep 18, 2016 · 4 comments
Closed

Relative <Link/>s not working in v4 #3901

vkbansal opened this issue Sep 18, 2016 · 4 comments

Comments

@vkbansal
Copy link

Version

v4.0.0-alpha.3

//URL Address Bar: localhost/foo/bar
const Foo = ({pathname}) => (
    <div>
     Foo
     <Match pattern={`${pathname}\bar`} component={Bar}/>
    </div>
)

const Bar = ({pathname}) => (
    <div>
     Bar
    <Link to='../'>Go Back</Link>
    </div>
)

Expected Behavior

Upon Clicking on the <Link to='../'>Go Back</Link>:

  1. must go to localhost/foo.
  2. Rendered Component should change

Actual Behavior

Upon Clicking on the Link:

  1. goes to localhost/foo.
  2. Rendered Component should change. Current component gets unmounted but new component is not rendered
@timdorr
Copy link
Member

timdorr commented Sep 19, 2016

I'm not sure if they're supposed to work yet or not. We definitely don't have ".." URLs handled.

@timdorr timdorr added this to the v4.0.0 milestone Sep 19, 2016
@timdorr
Copy link
Member

timdorr commented Sep 19, 2016

Actually, they work, you just need to build the URL yourself: https://react-router-website-uxmsaeusnn.now.sh/recursive-paths

@timdorr timdorr closed this as completed Sep 19, 2016
@vkbansal
Copy link
Author

Yes I've seen that example. It demonstrates relative links that go deep and not the other way around. It would be great to have example for it too.

@ryanflorence
Copy link
Member

These are really tricky to make work since it's relative to current match, not the actual url, @mjackson has some PoC code on his machine for this, but it's a tricky problem. For now you could take props.pathname or props.pattern, which is relative to the current matched component, and build the url with a path utility.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants