fix(acl): cannot read properties of undefined (reading 'fields')

This commit is contained in:
chenos 2022-11-22 16:00:40 +08:00
parent 466aa4987e
commit 54e92918b2

View File

@ -1,5 +1,5 @@
import { SchemaKey } from '@formily/react';
import { reduce ,unionBy} from 'lodash';
import { reduce, unionBy } from 'lodash';
import { useContext } from 'react';
import { useAPIClient } from '../../api-client';
import { CollectionContext } from '../context';
@ -11,8 +11,8 @@ export const useCollection = () => {
const api = useAPIClient();
const resource = api?.resource(collection?.name);
const { getInheritCollections, getCurrentCollectionFields } = useCollectionManager();
const currentFields = collection.fields;
const inheritKeys = getInheritCollections(collection.name);
const currentFields = collection?.fields || [];
const inheritKeys = getInheritCollections(collection?.name) || [];
const inheritedFields = reduce(
inheritKeys,
(result, value) => {