question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Link params not working

See original GitHub issue

I have tried the following combos:

With href: works, but reloads the whole page and says 404 for 3 seconds. <Link href={'/blog/'+post.id}><a>{post.title}</a></Link>

With params: The href looks good, but clicking the link throw an error (see below). <Link route='blog/entry' params={{id: post.id}}><a>{post.title}</a></Link>

With to: The href looks good, but clicking the link throw an error (see below). <Link to={'/blog/'+post.id}><a>{post.title}</a></Link>

Error:

TypeError: Cannot read property 'id' of undefined
    at Post (http://localhost:3000/_next/1509617163196/page/blog/entry:43023:55)
    at mountIndeterminateComponent (http://localhost:3000/_next/1509617163196/commons.js:10406:15)
    at beginWork (http://localhost:3000/_next/1509617163196/commons.js:10607:16)
    at performUnitOfWork (http://localhost:3000/_next/1509617163196/commons.js:12579:16)
    at workLoop (http://localhost:3000/_next/1509617163196/commons.js:12688:28)
    at HTMLUnknownElement.callCallback (http://localhost:3000/_next/1509617163196/commons.js:1305:14)
    at Object.invokeGuardedCallbackDev (http://localhost:3000/_next/1509617163196/commons.js:1344:16)
    at invokeGuardedCallback (http://localhost:3000/_next/1509617163196/commons.js:1201:27)
    at performWork (http://localhost:3000/_next/1509617163196/commons.js:12806:7)
    at scheduleUpdateImpl (http://localhost:3000/_next/1509617163196/commons.js:13191:19)

The Link is in components/PostList.js.

Src:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mergebanditcommented, Nov 29, 2017

FWIW, submitted a PR for null param values (not sure this solves the OPs issue, but is tangentially related)

0reactions
fridayscommented, Dec 1, 2017

Hi @bdombro please try to move asynchronous data fetching into getInitialProps, so Next.js will wait with the rendering until all required data (like post object) is available. That should be here in your code: https://github.com/benevolenttech/apollo-cms/blob/link-params-test2b/pages/blog/entry.js#L12

Read more comments on GitHub >

github_iconTop Results From Across the Web

React router not working with params - Stack Overflow
it works for me too! in my case it works because if the base url is not set, it will try to load...
Read more >
The Complete Guide to URL parameters with React Router
URL parameters are parameters whose values are set dynamically in a page's URL. In this post you'll learn how to use URL parameters...
Read more >
link to dynamic route with query params not working client-side
I think it's not possible to create a Link for dynamic route with query params in a way which would work both server-side...
Read more >
How to Access URL Parameters Using React Router 6
2️⃣ How to Retrieve URL Parameters Using Class Components. Class Components do not have access to Hooks so they cannot use useParams() ...
Read more >
URL Parameters not working - WordPress.org
Hello there,. After opening the lists I would like to show ads based on utm parameters. The parameter I have tried with is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found