Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

getinitialprops to a hoc in next js

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #getinitialprops #hoc #js
ADD COMMENT
Topic
Name
6+4 =