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

Does RouterContext.push() take an absolute or relative path? #2829

Closed
pdeva opened this issue Jan 4, 2016 · 6 comments
Closed

Does RouterContext.push() take an absolute or relative path? #2829

pdeva opened this issue Jan 4, 2016 · 6 comments

Comments

@pdeva
Copy link

pdeva commented Jan 4, 2016

This is not defined at all in the documentation.

If I am in route /A and want to get to route /A/B, do i do

routerContext.push('B')

or

routerContext.push('A/B')

or

//note the forward slash in the begining
routerContext.push('/A/B')

If its any of the latter two, how do i know the current 'path' so i can append /B to it?

@taion
Copy link
Contributor

taion commented Jan 4, 2016

In general our paths are absolute, not relative. For further questions, try Stack Overflow or Reactiflux.

@taion taion closed this as completed Jan 4, 2016
@pdeva
Copy link
Author

pdeva commented Jan 4, 2016

in that case i have come across a bug.

when in '/A` i do

    onEmailSubmit(email)
    {
        this.context.router.push('B');
    }

it takes me to /B instead of /A/B.

should i open a new case for this or will this one do?

@timdorr
Copy link
Member

timdorr commented Jan 4, 2016

That is not a bug. We do not support relative paths. You must push an absolute path. This is going to be addressed in #2172.

@pdeva
Copy link
Author

pdeva commented Jan 4, 2016

@timdorr

  1. this should be documented somewhere.
  2. passing the absolute path reloads the entire page, wiping out the state of the parent components.is that expected?

pdeva added a commit to pdeva/react-router that referenced this issue Jan 4, 2016
@timdorr
Copy link
Member

timdorr commented Jan 4, 2016

Apologies, I was thinking about Link.

In general, you should use absolute paths where possible. Using relative paths results in ambiguity. What happens when you are in a nested route structure? What happens when you're not? You're going to end up in two different locations. This will create unexpected behavior and bugs in your apps.

@pdeva
Copy link
Author

pdeva commented Jan 4, 2016

i am now confused.

if relative paths are indeed supported, then

  1. why doesnt my example above work
  2. also pushing absolute url shouldnt reload the entire page

or am i doing something wrong?

@remix-run remix-run deleted a comment from j-5-s Apr 19, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jun 18, 2018
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

3 participants