Skip to content

Commit

Permalink
Merge pull request #185 from luke358/fix/collapse-items
Browse files Browse the repository at this point in the history
fix: collapse children will be removed
  • Loading branch information
codebdy authored Jul 25, 2023
2 parents faefa91 + 3a29dea commit 829b4e5
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions apps/example-antd5/src/ResourceWidget/ResourceCollapsePanel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Collapse, Row } from "antd"
import { useCallback, useEffect, useState } from "react"
import { Collapse, CollapseProps, Row } from "antd"
import { useCallback, useEffect, useMemo, useState } from "react"

const key = "collapse-panel"
export const ResourceCollapsePanel = (
Expand All @@ -18,6 +18,13 @@ export const ResourceCollapsePanel = (
setExpanded(!!activedKey)
}, [])

const items: CollapseProps['items'] = useMemo(() => ([{
key,
label: title,
children: <Row gutter={0}>
{children}
</Row>
}]), [title, children])

return (
<Collapse
Expand All @@ -26,13 +33,8 @@ export const ResourceCollapsePanel = (
ghost
//expandIconPosition="end"
onChange={handleChange}
items={items}
{...other}
>
<Collapse.Panel header={<div>{title}</div>} key={key}>
<Row gutter={0}>
{children}
</Row>
</Collapse.Panel>
</Collapse>
/>
)
}

0 comments on commit 829b4e5

Please sign in to comment.