I have a HOC-wrapped-functional-component here
export default wrapperHoc( function myComponent ({ someProps }){
return(
<div/>
)
})
How do i write getInitialProps
for myComponent
?
Should i call myComponent
's getInitialProps
in wrapperHoc
?
const YourNewComponent = wrapperHoc(...)
YourNewComponent.getInitialProps = async (ctx) => {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const json = await res.json()
return { stars: json.stargazers_count }
}
export default YourNewComponent