chore(RecordProviderV2): add parentCollectionName prop

This commit is contained in:
Zeke Zhang 2024-02-06 19:36:14 +08:00
parent 3e4f7a36cc
commit 6c00c8c681

View File

@ -13,6 +13,10 @@ export interface RecordProviderPropsV2<DataType = {}, ParentDataType = {}> {
* collection name
*/
collectionName?: string;
/**
* collection name
*/
parentCollectionName?: string;
}
export const RecordProviderV2: FC<RecordProviderPropsV2> = ({
@ -21,14 +25,15 @@ export const RecordProviderV2: FC<RecordProviderPropsV2> = ({
parentRecord,
children,
collectionName,
parentCollectionName,
}) => {
const parentRecordValue = useMemo(() => {
if (parentRecord) {
if (parentRecord instanceof RecordV2) return parentRecord;
return new RecordV2({ data: parentRecord, collectionName });
return new RecordV2({ data: parentRecord, collectionName: parentCollectionName });
}
if (record instanceof RecordV2) return record.parentRecord;
}, [collectionName, parentRecord, record]);
}, [parentCollectionName, parentRecord, record]);
const currentRecordValue = useMemo(() => {
let res: RecordV2;