You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* The fieldSchemaMap that is created before form state is built is made available here.
*/
fieldSchemaMap: FieldSchemaMap
/**
* Server Components will also have available to the entire form state.
* We cannot add it to ClientComponentProps as that would blow up the size of the props sent to the client.
*/
formState: FormState
i18n: I18nClient
id?: number|string
operation: Operation
payload: Payload
permissions: SanitizedFieldPermissions
preferences: DocumentPreferences
req: PayloadRequest
siblingData: Data
user: User
}
This type is exported from admin/forms/Field.ts, is this the correct place?
But more important, is this the correct type to use for an admin server component?
I got this error after I tried to get props.req.url:
[ Server ] Error: Cannot read properties of undefined (reading 'url')
Debugging the code I didn't found req inside the props object but there is a params field which is not present inside the type.
If you use the reproduction repo, just simply pnpm install cd reproduction pnpm generate:importmap pnpm thisdev
Be careful to run the thisdev script from reproduction folder.
--
Or if you want to run it by yourself:
Really simple, just add a beforeLogin to admin components.
Describe the Bug
I am trying to build a plugin and I was trying to add a new react server component to the beforeLogin.
The type
ServerComponentProps
define areq
field of typePayloadRequest
payload/packages/payload/src/admin/forms/Field.ts
Lines 70 to 94 in 4c8cafd
This type is exported from admin/forms/Field.ts, is this the correct place?
But more important, is this the correct type to use for an admin server component?
I got this error after I tried to get
props.req.url
:Debugging the code I didn't found req inside the props object but there is a params field which is not present inside the type.
Link to the code that reproduces this issue
https://github.com/b3nab/payload/tree/repro/server-component-props-type-mismatch
Reproduction Steps
If you use the reproduction repo, just simply
pnpm install
cd reproduction
pnpm generate:importmap
pnpm thisdev
Be careful to run the thisdev script from
reproduction
folder.--
Or if you want to run it by yourself:
Really simple, just add a beforeLogin to admin components.
The BeforeLoginServer.ts
If you don't have a user collection with auth: true, here is one you can copy/paste inside the
collections
field of payload config:Which area(s) are affected? (Select all that apply)
area: core
Environment Info
The text was updated successfully, but these errors were encountered: