Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
cb565d69
Unverified
Commit
cb565d69
authored
Apr 06, 2022
by
Samuel
Committed by
GitHub
Apr 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update: Add appropriate error message when for getServerSideProps invalid return value (#35887)
parent
07723be8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
invalid-getserversideprops-return-value.md
errors/invalid-getserversideprops-return-value.md
+21
-0
manifest.json
errors/manifest.json
+4
-0
render.tsx
packages/next/server/render.tsx
+7
-2
No files found.
errors/invalid-getserversideprops-return-value.md
0 → 100644
View file @
cb565d69
# Invalid getServerSideProps Return Value
#### Why This Error Occurred
In one of the page's
`getServerSideProps`
the return value had the incorrect shape.
#### Possible Ways to Fix It
Make sure to return the following shape from
`getServerSideProps`
:
```
ts
export
async
function
getServerSideProps
(
ctx
:
GetServerSidePropsContext
)
{
return
{
props
:
{
[
key
:
string
]:
any
}
}
}
```
### Useful Links
-
[
getServerSideProps
](
https://nextjs.org/docs/api-reference/data-fetching/get-server-side-props
)
errors/manifest.json
View file @
cb565d69
...
@@ -645,6 +645,10 @@
...
@@ -645,6 +645,10 @@
{
{
"title"
:
"import-next"
,
"title"
:
"import-next"
,
"path"
:
"/errors/import-next.md"
"path"
:
"/errors/import-next.md"
},
{
"title"
:
"invalid-getserversideprops-return-value"
,
"path"
:
"/errors/invalid-getserversideprops-return-value.md"
}
}
]
]
}
}
...
...
packages/next/server/render.tsx
View file @
cb565d69
...
@@ -255,12 +255,17 @@ export type RenderOptsPartial = {
...
@@ -255,12 +255,17 @@ export type RenderOptsPartial = {
export
type
RenderOpts
=
LoadComponentsReturnType
&
RenderOptsPartial
export
type
RenderOpts
=
LoadComponentsReturnType
&
RenderOptsPartial
const
invalidKeysMsg
=
(
methodName
:
string
,
invalidKeys
:
string
[])
=>
{
const
invalidKeysMsg
=
(
methodName
:
'getServerSideProps'
|
'getStaticProps'
,
invalidKeys
:
string
[]
)
=>
{
const
docsPathname
=
`invalid-
${
methodName
.
toLocaleLowerCase
()}
-value`
return
(
return
(
`Additional keys were returned from \`
${
methodName
}
\`. Properties intended for your component must be nested under the \`props\` key, e.g.:`
+
`Additional keys were returned from \`
${
methodName
}
\`. Properties intended for your component must be nested under the \`props\` key, e.g.:`
+
`\n\n\treturn { props: { title: 'My Title', content: '...' } }`
+
`\n\n\treturn { props: { title: 'My Title', content: '...' } }`
+
`\n\nKeys that need to be moved:
${
invalidKeys
.
join
(
', '
)}
.`
+
`\n\nKeys that need to be moved:
${
invalidKeys
.
join
(
', '
)}
.`
+
`\nRead more: https://nextjs.org/docs/messages/
invalid-getstaticprops-value
`
`\nRead more: https://nextjs.org/docs/messages/
${
docsPathname
}
`
)
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment