React + Shopify Issue. getIntialProps has no context data

StevenPetteruti
New Member
7 0 0
Hey guys, having a strange problem with my next.js + react app, where I’m unable to load context query parameters (e.g. the name of the shop) at the component level, but I am within my pages route.
static async getInitialProps(ctx) {
console.log(ctx.query.shop)
return {}
}
This logs the shop parameter when I’m directly in a component from my /pages/page1 route in page1.js on react (which is at the path `/pages/page1.js` in my next.js project). However, when instead I put the code in /pages/page1/component and then navigate to that component from a button link in my react app:
 <Button url={`/page1/component`} plain>Navigate</Button>
The getInitialProps method fires, however no ctx.query object is on it - therefore I have no way to get the shopify data I need to render the page
0 Likes