Repository navigation
fix(ui): temporarily reverts custom component prop threading - #7474
Merged
Merged
Conversation
jmikrut
enabled auto-merge (squash)
August 2, 2024 01:44
Member
|
Related: #7360 |
4 tasks done
jacobsfletch
added a commit
that referenced
this pull request
Aug 20, 2024
#7754) ## Description Threads the field config to all "field subcomponents" through props, i.e. field label, description, error, etc. This way, the field config that controls any particular component is easily accessible and strongly typed, i.e. `props.field.maxLength`. This is true for both server and client components, whose server-side props are now also contextually typed. This behavior was temporarily removed in #7474 due to bloating HTML, but has since been resolved in #7620. This PR also makes significant improvements to component types by exporting explicit types for _every component of every field_, each with its own client/server variation. Now, a custom component can look something like this: ```tsx import type { TextFieldLabelServerComponent } from 'payload' import React from 'react' export const CustomLabel: TextFieldLabelServerComponent = (props) => { return ( <div>{`The max length of this field is: ${props?.field?.maxLength}`}</div> ) } ``` The following types are now available: ```ts import type { TextFieldClientComponent, TextFieldServerComponent, TextFieldLabelClientComponent, TextFieldLabelServerComponent, TextFieldDescriptionClientComponent, TextFieldDescriptionServerComponent, TextFieldErrorClientComponent, TextFieldErrorServerComponent, // ...and so one for each field } from 'payload' ``` BREAKING CHANGES: In order to strictly type these components, a few breaking changes have been made _solely to type definitions_. This only effects you if you are heavily using custom components. Old ```ts import type { ErrorComponent, LabelComponent, DescriptionComponent } from 'payload' ``` New: ```ts import type { FieldErrorClientComponent, FieldErrorServerComponent, FieldLabelClientComponent, FieldLabelServerComponent, FieldDescriptionClientComponent, FieldDescriptionServerComponent, // Note: these are the generic, underlying types of the more stricter types described above ^ // For example, you should use the type that is explicit for your particular field and environment // i.e. `TextFieldLabelClientComponent` and not simply `FieldLabelClientComponent` } from 'payload' ``` - [x] I have read and understand the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## Checklist: - [x] I have added tests that prove my fix is effective or that my feature works - [x] Existing test suite passes locally with my changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The following config caused the html size to grow to 500mb: