fix(client): cannot read properties of undefined (reading 'target')

This commit is contained in:
chenos 2022-06-29 23:04:49 +08:00
parent 947215f96d
commit 017c6f232d

View File

@ -43,12 +43,17 @@ export const useCollectionManager = () => {
return;
}
let cName = collectionName;
return fieldNames.reduce((result, curFieldName) => {
const collectionField = getCollectionField(`${cName}.${curFieldName}`);
cName = collectionField.target;
return collectionField;
}, null);
let collectionField;
while (cName && fieldNames.length > 0) {
const fileName = fieldNames.shift();
collectionField = getCollectionField(`${cName}.${fileName}`);
if (collectionField?.target) {
cName = collectionField.target;
} else {
cName = null;
}
}
return collectionField;
},
getInterface(name: string) {
return interfaces[name] ? clone(interfaces[name]) : null;