chore: improves field types (#9172)
### What? Ensures `path` is required and only present on the fields that expect it (all fields except row). Deprecates `useFieldComponents` and `FieldComponentsProvider` and instead extends the RenderField component to account for all field types. This also improves type safety within `RenderField`. ### Why? `path` being optional just adds DX overhead and annoyance. ### How? Added `FieldPaths` type which is added to iterable field types. Placed `path` back onto the ClientFieldBase type.
This commit is contained in:
@@ -4,22 +4,6 @@ import type { TextFieldClientComponent } from 'payload'
|
||||
import { TextField } from '@payloadcms/ui'
|
||||
import React from 'react'
|
||||
|
||||
export const MyClientFieldComponent: TextFieldClientComponent = ({
|
||||
field,
|
||||
indexPath,
|
||||
parentPath,
|
||||
parentSchemaPath,
|
||||
path,
|
||||
schemaPath,
|
||||
}) => {
|
||||
return (
|
||||
<TextField
|
||||
field={field}
|
||||
indexPath={indexPath}
|
||||
parentPath={parentPath}
|
||||
parentSchemaPath={parentSchemaPath}
|
||||
path={path}
|
||||
schemaPath={schemaPath}
|
||||
/>
|
||||
)
|
||||
export const MyClientFieldComponent: TextFieldClientComponent = (props) => {
|
||||
return <TextField {...props} />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user