chore(default): avoid crashing

This commit is contained in:
Rain 2023-10-09 12:12:33 +08:00
parent 3b53d7c623
commit fa3127e467
2 changed files with 21 additions and 0 deletions

View File

@ -39,6 +39,13 @@ const ToOneNester = (props) => {
const recordRef = React.useRef(_.omit(record, '__parent'));
const isAllowToSetDefaultValue = useCallback(({ form, fieldSchema, collectionField, getInterface }) => {
if (!collectionField) {
if (process.env.NODE_ENV !== 'production') {
console.error(`collectionField should not be ${collectionField}`);
}
return false;
}
// 当 Field component 不是下列组件时,不允许设置默认值
if (
collectionField.target &&
@ -85,6 +92,13 @@ const ToManyNester = observer(
}
const isAllowToSetDefaultValue = useCallback(({ form, fieldSchema, collectionField, getInterface }) => {
if (!collectionField) {
if (process.env.NODE_ENV !== 'production') {
console.error(`collectionField should not be ${collectionField}`);
}
return false;
}
// 当 Field component 不是下列组件时,不允许设置默认值
if (
collectionField.target &&

View File

@ -98,6 +98,13 @@ function _isAllowToSetDefaultValue({
);
}
if (!collectionField) {
if (process.env.NODE_ENV !== 'production') {
console.error(`collectionField should not be ${collectionField}`);
}
return false;
}
// 当 Field component 不是下列组件时,不允许设置默认值
if (
collectionField.target &&