-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LinkToDocClient server pre-rendering fails #10041
Comments
The error happens while destructuring the useConfig() result:
|
Hey @cbratschi I'll investigate here, but just wanted to let you know the reason why you're not seeing those optional chaining checks in the js is because those changes haven't been released yet after being merged in. This is why you see them in the source but can't find an instance of them. PR for it was here. |
Hey @cbratschi, The PR I linked above was included in 3.9.0! I can't reproduce a runtime error on search docs with undefined related docs anymore. I'm also not getting an error related to config otherwise. Can you confirm with latest? |
I'm seeing a similar issue when attempting to use useField on a custom component. It's fine using useConfig within the component itself but whenever I use useField it fails with the same webpack error above "Cannot destructure property 'config'" This is pretty critical as it's totally preventing the use of custom components... |
Describe the Bug
The component uses for instance useConfig() and useField(). Both returned values are used right away in the component without verifying if they are defined. While server rendering config is undefined and the code fails:
TypeError: Cannot read properties of undefined (reading 'config')
Changes are needed here:
https://github.com/payloadcms/payload/blob/main/packages/plugin-search/src/Search/ui/LinkToDoc/index.client.tsx#L17
The optional chaining used here is no longer in the transpilled JavaScript code:
https://github.com/payloadcms/payload/blob/main/packages/plugin-search/src/Search/ui/LinkToDoc/index.client.tsx#L21
Link to the code that reproduces this issue
https://github.com/cbratschi/payload
Reproduction Steps
Create a search collection, open the collection in the admin panel and select a document. Error occurs here.
Which area(s) are affected? (Select all that apply)
plugin: search
Environment Info
The text was updated successfully, but these errors were encountered: