Skip to content

Commit

Permalink
feat(descriptions): 去掉条件判断
Browse files Browse the repository at this point in the history
  • Loading branch information
xiamiao committed Jun 28, 2024
1 parent 047eb48 commit dc590ca
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/ui/descriptions/src/Descriptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { DescriptionsItem, DescriptionsItemProps } from './DescriptionsItem'

const DESCRIPTIONS_PREFIX = getPrefixCls('descriptions')

const DEFAULT_DATA = [] as []

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

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

0 comments on commit dc590ca

Please sign in to comment.