Router: Redirect doesn't work with relative links

Created on 1 Jul 2018  路  3Comments  路  Source: reach/router

I try use Redirect in a nested Route components, but it seems that the "from" supports relative link but the "to" props doesn't supports relative links, which is odd銆俌ou can see it in the demo

bug

Most helpful comment

Is this still working properly? I seem to be experiencing the same issue. Here's an example:

<ProfilePage path="/profile">
    <Redirect from="/" to="about" /> {/* redirects to `localhost.com/about` instead of `localhost.com/profile/about`  */}
    <AboutPage default path="/about" />
    <SettingsPage path="/settings" />
</ProfilePage>

Maybe I'm using this incorrectly though?

I want to do this because I'm also using isPartiallyCurrent to style active tabs with multiple nav levels. So I need the link to be <Link to="/profile"> but redirect to /profile/about so that isPartiallyCurrent will be true for the profile nav link and the about nav link.

An alternative could be to just use the about page as the default and not add the /about path but then the about nav link gets highlighted for all sub nav paths.

Any insight would be appreciated!

All 3 comments

@ryanflorence Hey there, I encountered the same issue recently. I'm wondering are there any plan to fix this, because the pr is still open. Thanks :)

Is this still working properly? I seem to be experiencing the same issue. Here's an example:

<ProfilePage path="/profile">
    <Redirect from="/" to="about" /> {/* redirects to `localhost.com/about` instead of `localhost.com/profile/about`  */}
    <AboutPage default path="/about" />
    <SettingsPage path="/settings" />
</ProfilePage>

Maybe I'm using this incorrectly though?

I want to do this because I'm also using isPartiallyCurrent to style active tabs with multiple nav levels. So I need the link to be <Link to="/profile"> but redirect to /profile/about so that isPartiallyCurrent will be true for the profile nav link and the about nav link.

An alternative could be to just use the about page as the default and not add the /about path but then the about nav link gets highlighted for all sub nav paths.

Any insight would be appreciated!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ssured picture ssured  路  3Comments

sseppola picture sseppola  路  4Comments

EJIqpEP picture EJIqpEP  路  4Comments

Kadrian picture Kadrian  路  5Comments

ricardobrandao picture ricardobrandao  路  5Comments