When I am calling withRouter I am able to see the output when the data renders the second time.
My component looks like this:
const Home = (props) => {
console.log("all props", props)
let { router } = props
let { category, item } = router.query
console.log("Cat", category)
console.log("Item", item)
return (
<FirebaseContext.Provider value={new Firebase()}>
<div>
<Head>
<title>Category</title>
</Head>
<Navigation />
{/* <Item category={category} item={item} {...props} /> */}
</div>
</FirebaseContext.Provider>
)
}
Home.getInitialProps = async (props) => {
console.log(props)
return { req, query }
}
export default compose(withRouter, withAuthentication)(Home)
If you look at console, the very first render looks like:
asPath: "/c/cigars/1231"
back: ƒ ()
beforePopState: ƒ ()
events: {on: ƒ, off: ƒ, emit: ƒ}
pathname: "/c/[category]/[item]"
prefetch: ƒ ()
push: ƒ ()
query: {}
Why is query empty even though it clearly recognizes the asPath?