rsnext/errors/get-initial-props-as-an-instance-method.md
stefanprobst 279ae19c7e
docs: update links to docs site (#14305)
this updates some links to the docs site to their new location
2020-06-18 09:54:07 +00:00

673 B

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