import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import Chip from '@material-ui/core/Chip'; import Paper from '@material-ui/core/Paper'; // TODO: fix the style const styles = makeStyles(theme => ({ root: { display: 'flex', justifyContent: 'center', flexWrap: 'wrap', padding: theme.spacing(0.5), }, chip: { margin: theme.spacing(0.5), }, })); export default function ChipsArray() { const classes = useStyles(); const [chipData, setChipData] = React.useState([ { key: 0, label: 'Angular' }, { key: 1, label: 'jQuery' }, { key: 2, label: 'Polymer' }, { key: 3, label: 'React' }, { key: 4, label: 'Vue.js' }, ]); const handleDelete = chipToDelete => () => { if (chipToDelete.label === 'React') { alert('Why would you want to delete React?! :)'); return; } setChipData(chips => chips.filter(chip => chip.key !== chipToDelete.key)); }; return ( {chipData.map(data => { return ( ); })} ); }