-
Notifications
You must be signed in to change notification settings - Fork 38
Not working with Dynamic Routing #41
Comments
So my issue was I had to use the query object along with getInitialProps in the dynamic pages. I was using the router to compare the data and return the proper object for specific posts. When I would navigate from that page the variable I stored it in would return undefined because the query object would be empty. Still not 100% sure why it calls everything again on that page when navigating away from it however. |
I have same problem. @alenart91 |
Hey, I have the same exact problem. In getInitialProps I check if the query route exists in redux state. When clicking away from the page, the clicked route shows in title, then 404 error shows and then again the page renders. |
If someone can provide a small, self-contained example of this failure, I can look into this. I haven't used dynamic routing and I'm not very familiar with it. |
I solved this by caching whatever you're fetching from the router in a variable. Then I fallback to that variable if the value is null: let cachedSlug = null
export default () => {
const router = useRouter()
const { slug = cachedSlug } = router.query
cachedSlug = slug
return (...)
} Hope this help. |
Wrapping the component in _app.js with the page transition component throws an error once you try to navigate anywhere from a post using dynamic routing. Using the most basic form from the example without any styling.
Here's an example of my blog page using the dynamic routing links
and the actual page itself
I'm using next 9.0.3
The text was updated successfully, but these errors were encountered: