| 1 |
import { useState } from 'react'; |
| 2 |
import { Chip, ChipGroup } from '@patternfly/react-core/deprecated'; |
| 3 |
|
| 4 |
export const ChipGroupInline: React.FunctionComponent = () => { |
| 5 |
const [chips, setChips] = useState([ |
| 6 |
'Chip one', |
| 7 |
'Really long chip that goes on and on', |
| 8 |
'Chip three', |
| 9 |
'Chip four', |
| 10 |
'Chip five' |
| 11 |
]); |
| 12 |
|
| 13 |
const deleteItem = (id: string) => { |
| 14 |
const copyOfChips = [...chips]; |
| 15 |
const filteredCopy = copyOfChips.filter((chip) => chip !== id); |
| 16 |
setChips(filteredCopy); |
| 17 |
}; |
| 18 |
|
| 19 |
return ( |
| 20 |
<ChipGroup> |
| 21 |
{chips.map((currentChip) => ( |
| 22 |
<Chip key={currentChip} onClick={() => deleteItem(currentChip)}> |
| 23 |
{currentChip} |
| 24 |
</Chip> |
| 25 |
))} |
| 26 |
</ChipGroup> |
| 27 |
); |
| 28 |
}; |