Skip to content

Commit

Permalink
fix(descriptions): 去掉data默认值
Browse files Browse the repository at this point in the history
  • Loading branch information
zyprepare committed Jun 29, 2024
1 parent 9f37b1e commit c5149e1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/ui/descriptions/src/Descriptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import { DescriptionsItem, DescriptionsItemProps } from './DescriptionsItem'

const DESCRIPTIONS_PREFIX = getPrefixCls('descriptions')

const DEFAULT_DATA = [] as []

/**
* 描述列表组件
*/
Expand All @@ -26,7 +24,7 @@ export const Descriptions = forwardRef<HTMLDivElement | null, DescriptionsProps>
role = 'descriptions',
className,
children,
data = DEFAULT_DATA,
data,
fieldNames,
column = 3,
placement = 'horizontal',
Expand All @@ -44,7 +42,10 @@ export const Descriptions = forwardRef<HTMLDivElement | null, DescriptionsProps>
const vertical = placement === 'vertical'
const bordered = appearance === 'table' || noBackground

const transformedData = useMemo(() => transformData(data, fieldNames), [data, fieldNames])
const transformedData = useMemo(() => {
if (data) return transformData(data, fieldNames)
return data
}, [data, fieldNames])
// 如果配置了data,则使用配置模式渲染,否则取 children
const computeChildren = transformedData
? computeItems(transformedData)
Expand Down

0 comments on commit c5149e1

Please sign in to comment.