Improve error message when returning props.data from field hook #6750
AlessioGr
started this conversation in
Feature Requests & Ideas
Replies: 2 comments 1 reply
-
Thank god this is the Google result. |
Beta Was this translation helpful? Give feedback.
0 replies
-
During development i had a hook that did nothing and an error like this was triggered. Thank God this was the first Google result.
And here is the error that was thrown |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
To Reproduce
Will throw the following error:
[12:24:10] ERROR (payload): RangeError: Maximum call stack size exceeded
at [Symbol.hasInstance] ()
at deepCopyObject (/Users/alessio/Documents/GitHub/payload/dist/utilities/deepCopyObject.js:4:17)
at /Users/alessio/Documents/GitHub/payload/dist/utilities/deepCopyObject.js:14:74
at Array.forEach ()
at deepCopyObject (/Users/alessio/Documents/GitHub/payload/dist/utilities/deepCopyObject.js:11:27)
at /Users/alessio/Documents/GitHub/payload/dist/utilities/deepCopyObject.js:14:74
at Array.forEach ()
at deepCopyObject (/Users/alessio/Documents/GitHub/payload/dist/utilities/deepCopyObject.js:11:27)
at /Users/alessio/Documents/GitHub/payload/dist/utilities/deepCopyObject.js:14:74
at Array.forEach ()
Describe the Bug
Optimally, it should be typed in a way where you can only return props.value / the correct value, and not props.data.
In any case, the error message should be improved. This is something which could happen by accident, as it's totally okay to return
props.data
from a collection hook, but field hooks need to returnprops.value
instead. (And yes, this just happened to brainless me. I can imagine I wouldn't be the only one)Payload Version
1.9.1
Related PR
#2851
Beta Was this translation helpful? Give feedback.
All reactions