Skip to content
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

FieldServerComponent cannot be passed functions in serverProps #9895

Closed
sacha-c opened this issue Dec 11, 2024 · 4 comments · Fixed by #9898
Closed

FieldServerComponent cannot be passed functions in serverProps #9895

sacha-c opened this issue Dec 11, 2024 · 4 comments · Fixed by #9898
Assignees

Comments

@sacha-c
Copy link

sacha-c commented Dec 11, 2024

Describe the Bug

It seems like custom Field components are not rendered as server components.

I am trying to pass a function as a prop to a custom Field component. Since V3 we are using NextJS, I am ensuring this component is a server-side component & thus not including the use client directive. In addition I am passing my props using the serverProps.

However when I start the server it fails with Functions cannot be passed directly to Client Components

Note that I've tried with Collection-level components, and there, it works! I've only experienced this issue on Field components so far

Link to the code that reproduces this issue

sacha-c@64dd976

Reproduction Steps

Have a custom component

import type { FieldServerComponent } from 'payload'

const FieldServerComponentIssue: FieldServerComponent<any, any, { value: () => string }> = (
  props,
) => {
  return <div>{props.value()}</div>
}

export default FieldServerComponentIssue

Have a configuration which passes an unserializable prop in the Field's component:

    ...
    {
      name: 'bugReproduction',
      type: 'ui',
      admin: {
        components: {
          Field: {
            path: 'test/_community/components/FieldServerComponentIssue',
            serverProps: {
              myValue: () => 'hello world', // As a serverProp, I expect to be able to pass function and other unserializable data
            },
          },
        },
      },
    },

Which area(s) are affected? (Select all that apply)

area: ui

Environment Info

Payload: 3.5.0
Node: v22.6.0
Next: 15.0.3
@sacha-c sacha-c added status: needs-triage Possible bug which hasn't been reproduced yet validate-reproduction labels Dec 11, 2024
@AlessioGr AlessioGr self-assigned this Dec 11, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Dec 11, 2024
@AlessioGr AlessioGr added status: verified If an issue has been reproduced prioritized labels Dec 11, 2024
@github-actions github-actions bot removed the status: verified If an issue has been reproduced label Dec 11, 2024
@sacha-c
Copy link
Author

sacha-c commented Dec 11, 2024

Nice! Thank you for addressing this so quickly! 🚀

@AlessioGr
Copy link
Member

Thank you for reporting this! Surprised this didn't come up earlier

Copy link
Contributor

🚀 This is included in version v3.6.0

Copy link
Contributor

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants