I'm upgrading my projects to Payload 2.0 and I'm having a problem fixing extended components. Note that code samples below are not exact copies but instead simplified to ease the explanation.
I have following code in the collection config:
const items: CollectionConfig = {
slug: "items",
admin: {
components: {
views: {
Edit: { Default: CustomEditView },
},
},
},
};
The props for component that can be passed into CollectionConfig.admin.components.views.Edit.Default are the following:
interface EditViewComponentProps {
collection?: SanitizedCollectionConfig;
global?: SanitizedGlobalConfig;
user: User | null | undefined;
}
I'm extending component from module payload/components/views/Edit which have following props (combined into one interface here):
interface DefaultEditViewProps {
action: string;
apiURL: string;
canAccessAdmin?: boolean;
data: any;
isLoading: boolean;
onSave: (json: any) => void;
updatedAt: string;
user: User | null | undefined;
collection: SanitizedCollectionConfig;
disableActions?: boolean;
disableLeaveWithoutSaving?: boolean;
hasSavePermission?: boolean;
id: string;
initialState?: Fields;
internalState?: Fields;
isEditing?: boolean;
permissions: CollectionPermission | null;
customHeader?: React.ReactNode;
disableRoutes?: boolean;
}
So the question is, that is there an easy way to set props required by DefaultEditView and extend it using props provided into custom EditViewComponent? It used to be so that the custom component got all the props required by the default component, but that doesn't seem to be the case anymore.