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

getStaticProps used along with getStaticPaths is not updating the data for dynamic routes based on params #26944

Closed
Anam0927 opened this issue Jul 6, 2021 · 5 comments
Labels
bug Issue was opened via the bug report template.

Comments

@Anam0927
Copy link

Anam0927 commented Jul 6, 2021

What version of Next.js are you using?

11.0.1

What version of Node.js are you using?

14.17.1

What browser are you using?

Chrome

What operating system are you using?

Windows

How are you deploying your application?

next start

Describe the Bug

I've pages with URLs like /how-it-works/[id] which use getStaticProps and getStaticPaths. The problem occurs when I navigate to a similar route with different id. The data (from getStaticProps) is not updated. It remains as the data from the first time this route was accessed. If I refresh the page, the data gets updated but then the error occurs again when I try to navigate using links.

I'm accessing the data based on id through ctx.params in getStaticPaths.

The problem only started after upgrading to NextJS 11. This was working fine before.

I'm using next/link for navigating.

Expected Behavior

The data should get updated based on id when navigating using next/link.

To Reproduce

  1. Create a dynamic route page like /how-it-works/[id]
  2. Add getStaticPaths and getStaticProps to this page with data fetching based on id in getStaticProps.
  3. Add some next/link Links to routes with different ids.
  4. Try navigating using those links.
  5. Error occurs.
@Anam0927 Anam0927 added the bug Issue was opened via the bug report template. label Jul 6, 2021
@Anam0927
Copy link
Author

Anam0927 commented Jul 6, 2021

UPDATE:

Further investigation showed that the data is being changed in getStaticPaths but is not being reflected in the page component props

@timneutkens
Copy link
Member

Can you create a minimal reproduction, e.g. in a github repository or https://stackblitz.com/

@ijjk
Copy link
Member

ijjk commented Jul 15, 2021

Hi, this sounds like it could potentially be a duplicate of #26270

@ijjk
Copy link
Member

ijjk commented Sep 19, 2021

Closing per above as this appears to be a duplicate

@ijjk ijjk closed this as completed Sep 19, 2021
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

4 participants