Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Latest commit

 

History

History
39 lines (27 loc) · 675 Bytes

get-initial-props-as-an-instance-method.md

File metadata and controls

39 lines (27 loc) · 675 Bytes

getInitialProps was defined as an instance method

Why This Error Occurred

getInitialProps must be a static method in order to be called by next.js.

Possible Ways to Fix It

Use the static keyword.

export default class YourEntryComponent extends React.Component {
  static getInitialProps() {
    return {}
  }

  render() {
    return 'foo'
  }
}

or

const YourEntryComponent = function () {
  return 'foo'
}

YourEntryComponent.getInitialProps = () => {
  return {}
}

export default YourEntryComponent

Useful Links