From 54e92918b285745c2a768b72543cc82eb02399ed Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 22 Nov 2022 16:00:40 +0800 Subject: [PATCH] fix(acl): cannot read properties of undefined (reading 'fields') --- .../client/src/collection-manager/hooks/useCollection.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/collection-manager/hooks/useCollection.ts b/packages/core/client/src/collection-manager/hooks/useCollection.ts index c55a86b32..bc0c7a328 100644 --- a/packages/core/client/src/collection-manager/hooks/useCollection.ts +++ b/packages/core/client/src/collection-manager/hooks/useCollection.ts @@ -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) => {