rsnext/errors/gssp-component-member.mdx
Delba de Oliveira 44d1a1cb15
docs: Migrate error messages to MDX and App Router. (#52038)
This PR is part of a larger effort to migrate error messages to MDX and
use App Router: https://github.com/vercel/front/pull/23459
2023-07-05 06:11:16 -07:00

49 lines
958 B
Text

---
title: '`getStaticProps` / `getServerSideProps` can not be attached to the page component'
---
## Why This Error Occurred
On one of your page's components you attached either `getStaticProps`, `getStaticPaths`, or `getServerSideProps` as a member instead of as a separate export.
These methods can not be attached in the same way as `getInitialProps` and must be their own export
## Possible Ways to Fix It
Move the method to it's own export from your page.
**Before**
```jsx filename="pages/index.js"
function Page(props) {
return <p>hello world</p>
}
Page.getStaticProps = () => ({
props: {
hello: 'world',
},
})
export default Page
```
**After**
```jsx filename="pages/index.js"
function Page(props) {
return <p>hello world</p>
}
export default Page
export const getStaticProps = () => ({
props: {
hello: 'world',
},
})
```
## Useful Links
- [Data Fetching Docs](/docs/pages/building-your-application/data-fetching)