refactor(CollectionField): extract CollectionFieldInternalField component

This commit is contained in:
Zeke Zhang 2024-11-12 22:05:06 +08:00
parent 87f0ac38e4
commit cec5def70b

View File

@ -13,7 +13,7 @@ import { useDynamicComponentProps } from '../../hoc/withDynamicSchemaProps';
import { useComponent } from '../../schema-component'; import { useComponent } from '../../schema-component';
import { useCollectionField } from './CollectionFieldProvider'; import { useCollectionField } from './CollectionFieldProvider';
export const CollectionField = connect((props) => { const CollectionFieldInternalField = (props) => {
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
const { uiSchema } = useCollectionField(); const { uiSchema } = useCollectionField();
const Component = useComponent( const Component = useComponent(
@ -24,6 +24,10 @@ export const CollectionField = connect((props) => {
if (!uiSchema) return null; if (!uiSchema) return null;
return <Component {...props} {...dynamicProps} />; return <Component {...props} {...dynamicProps} />;
};
export const CollectionField = connect((props) => {
return <CollectionFieldInternalField {...props} />;
}); });
CollectionField.displayName = 'CollectionField'; CollectionField.displayName = 'CollectionField';