Closed corysimmons closed 1 year ago
Did you find your error ? i'm facing the same issue
No, I just ended up following the NextJS tutorial (which is the same use case—pretty slugs):
Maybe you should try a different approach. https://github.com/zeit/next.js/#fetching-data-and-component-lifecycle
Maybe this can help you.
Done some console logging and found that query
is not defined, but router is there. So in my setup, something similar to this is working:
// ./_app.js
// ...
const App = ({ Component, pageProps, query }) => (
<ApolloProvider client={GraphQLClient}>
<Component {...pageProps} query={query} />
</ApolloProvider>
)
App.getInitialProps = async ({ Component, ctx, router: { query } }) => {
let pageProps = {};
if(Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx);
}
return ({ pageProps, query })
}
export default App
I would expect to get some data in
article.js
, but it just returns nothing. Any ideas what I'm doing wrong?I just want to get the values of URL params for things like slugs and ids.