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

"asPath" is missing in url objects #2987

Closed
1 task done
gwn opened this issue Sep 25, 2017 · 3 comments
Closed
1 task done

"asPath" is missing in url objects #2987

gwn opened this issue Sep 25, 2017 · 3 comments

Comments

@gwn
Copy link
Contributor

gwn commented Sep 25, 2017

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

"asPath" information should be present in url objects that are passed as
properties to components, as documented in:
https://github.com/zeit/next.js/blob/master/readme.md#with-link

Each top-level component receives a url property with the following API:

...
asPath - String of the actual path (including the query) shows in the browser
...

Current Behavior

"asPath" is not present in url objects

Steps to Reproduce (for bugs)

  1. Check out the "url" properties of page components to see that "asPath" is missing

Notes

I'm aware that I can get "asPath" from the router object, but it looks like I should be able to get it from the url object as well.

@azza85
Copy link

azza85 commented Sep 26, 2017

@gwn do you have a code sample?

I can access it in getInitialProps as shown below.

<Link prefetch as={'/news/title-1'} href={'/news?title=title-1'}><a>{'Title 1'}</a></Link>
class News extends Component {
  static async getInitialProps({query,pathname,asPath}) {

returns

query =>  {title: "title-1"}
pathname =>  /news
asPath =>  /news/title-1

@timneutkens
Copy link
Member

@azza85 I know what he means 😄 Every top level page automatically gets this.props.url even if you don't use getInitialProps

@lock
Copy link

lock bot commented May 10, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

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