fix: view inherited collection field reported error (#2249)

This commit is contained in:
katherinehhh 2023-07-16 16:59:03 +08:00 committed by GitHub
parent 1d942d9910
commit aececf1952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ import { ISchema } from '@formily/react';
import { uid } from '@formily/shared';
import cloneDeep from 'lodash/cloneDeep';
import set from 'lodash/set';
import React, { useState } from 'react';
import React, { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider';
@ -65,14 +65,21 @@ export const ViewCollectionField = (props) => {
export const ViewFieldAction = (props) => {
const { scope, getContainer, item: record, children } = props;
const { getInterface } = useCollectionManager();
const { getInterface, collections } = useCollectionManager();
const [visible, setVisible] = useState(false);
const [schema, setSchema] = useState({});
const api = useAPIClient();
const { t } = useTranslation();
const compile = useCompile();
const [data, setData] = useState<any>({});
const currentCollections = useMemo(() => {
return collections.map((v) => {
return {
label: compile(v.title),
value: v.name,
};
});
}, []);
return (
<RecordProvider record={record}>
<ActionContextProvider value={{ visible, setVisible }}>
@ -113,6 +120,7 @@ export const ViewFieldAction = (props) => {
getContainer,
showReverseFieldConfig: !data?.reverseField,
createOnly: !true,
collections: currentCollections,
...scope,
}}
/>