I have an app with a single page index.js
, and I parse the query parameters in getInitialProps
:
static async getInitialProps ({query}) {
console.log('PAGE', query.screenId);
try {
const projectData = await ProjectLoader.loadProject(query);
return projectData;
}
catch (err) {
console.error(err);
}
};
I use <Link href={pathname, query} prefetch>
tags to build my links.
The screenId
property is key to finding the right page to render.
However, when I use the back button in the browser to a page without screenId
set, getInitialProps
doesn’t return screenId:undefined
as expected, but another value (as you can see in the console log):
When I refresh the page, I get the right properties and see the correct results.
The “imaginary” screenId
is actually a valid value, but I have no idea where this value comes from.
Why is this happening?