Skip to content

Commit

Permalink
Clarify error message in isSerializableProps
Browse files Browse the repository at this point in the history
  • Loading branch information
arturmuller authored Mar 7, 2021
1 parent 33255b7 commit e896570
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/next/lib/is-serializable-props.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const regexpPlainIdentifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/

function getObjectClassLabel(value: any): string {
return Object.prototype.toString.call(value)
}

function isPlainObject(value: any): boolean {
if (Object.prototype.toString.call(value) !== '[object Object]') {
if (getObjectClassLabel(value) !== '[object Object]') {
return false
}

Expand All @@ -19,7 +23,7 @@ export function isSerializableProps(
page,
method,
'',
`Props must be returned as a plain object from ${method}: \`{ props: { ... } }\`.`
`Props must be returned as a plain object from ${method}: \`{ props: { ... } }\` (received: \`${getObjectClassLabel(input)}\`).`
)
}

Expand Down

0 comments on commit e896570

Please sign in to comment.