diff --git a/packages/core/client/src/schema-component/antd/association-field/Nester.tsx b/packages/core/client/src/schema-component/antd/association-field/Nester.tsx index c95132611..49bb03fda 100644 --- a/packages/core/client/src/schema-component/antd/association-field/Nester.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/Nester.tsx @@ -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 && diff --git a/packages/core/client/src/schema-settings/hooks/useIsAllowToSetDefaultValue.tsx b/packages/core/client/src/schema-settings/hooks/useIsAllowToSetDefaultValue.tsx index ad0ca5589..c28fef394 100644 --- a/packages/core/client/src/schema-settings/hooks/useIsAllowToSetDefaultValue.tsx +++ b/packages/core/client/src/schema-settings/hooks/useIsAllowToSetDefaultValue.tsx @@ -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 &&