Closed coommark closed 5 years ago
Ah! I see that this is a Next.js issue, not reactivesearch. In one of their response they said "We don't have plans to add support for calling getInitialProps in nested components."
That settles it.
Yup, as far as I remember getInitialProps
can only be used at the page level. For passing it further down you could perhaps use react's context api if its at a nested level.
In the SSR samples, one can access the Next.JS context like this:
static async getInitialProps(ctx)
. So when youconsole.log(ctx)
you can access both thereq
andres
context objects. However, when you load a child component and try to access the context instatic async getInitialProps(ctx)
, the ctx is empty.Could this be a problem with the return statement of the parent's return statement of the
getInitialProps
? Is it swallowing up the ctx and not passing it down?Please how do I pass the ctx down to a child component such as a Navigation component so I can extract session information from the ctx?
Thank you.