mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
refactor: optimize CollectionField (#4111)
This commit is contained in:
parent
c26e43a34f
commit
5f8e442a15
@ -6,7 +6,7 @@ import React, { useCallback, useEffect, useMemo } from 'react';
|
|||||||
import { useFormBlockContext } from '../../block-provider/FormBlockProvider';
|
import { useFormBlockContext } from '../../block-provider/FormBlockProvider';
|
||||||
import { useCompile, useComponent } from '../../schema-component';
|
import { useCompile, useComponent } from '../../schema-component';
|
||||||
import { useIsAllowToSetDefaultValue } from '../../schema-settings/hooks/useIsAllowToSetDefaultValue';
|
import { useIsAllowToSetDefaultValue } from '../../schema-settings/hooks/useIsAllowToSetDefaultValue';
|
||||||
import { CollectionFieldContext, CollectionFieldProvider, useCollectionField } from './CollectionFieldProvider';
|
import { CollectionFieldProvider, useCollectionField } from './CollectionFieldProvider';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
component: any;
|
component: any;
|
||||||
@ -73,18 +73,12 @@ export const CollectionFieldInternalField: React.FC = (props: Props) => {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
field.dataSource = uiSchema.enum;
|
field.dataSource = uiSchema.enum;
|
||||||
const originalProps = compile(uiSchema['x-component-props']) || {};
|
const originalProps = compile(uiSchema['x-component-props']) || {};
|
||||||
const componentProps = merge(originalProps, field.componentProps || {});
|
field.componentProps = merge(originalProps, field.componentProps || {});
|
||||||
field.component = [
|
|
||||||
(props) => (
|
|
||||||
<CollectionFieldContext.Provider value={collectionField}>
|
|
||||||
<Component {...props} />
|
|
||||||
</CollectionFieldContext.Provider>
|
|
||||||
),
|
|
||||||
componentProps,
|
|
||||||
];
|
|
||||||
}, [uiSchema]);
|
}, [uiSchema]);
|
||||||
|
|
||||||
return null;
|
if (!uiSchema) return null;
|
||||||
|
|
||||||
|
return <Component {...props} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CollectionField = connect((props) => {
|
export const CollectionField = connect((props) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user