Buckets:
| --- | |
| title: '`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. | |
| ```jsx filename="pages/example.js" | |
| export default class YourEntryComponent extends React.Component { | |
| static getInitialProps() { | |
| return {} | |
| } | |
| render() { | |
| return 'foo' | |
| } | |
| } | |
| ``` | |
| or | |
| ```jsx filename="pages/example.js" | |
| const YourEntryComponent = function () { | |
| return 'foo' | |
| } | |
| YourEntryComponent.getInitialProps = () => { | |
| return {} | |
| } | |
| export default YourEntryComponent | |
| ``` | |
| ## Useful Links | |
| - [Fetching data and component lifecycle](/docs/pages/api-reference/functions/get-initial-props) | |
Xet Storage Details
- Size:
- 729 Bytes
- Xet hash:
- 9e928b4d29181e77b3e939607fc36927f1c1d558f6bda10c6b2e58766ef0ddba
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.