0
I want the phone input, when adding, and the user click enter or tab, (or even an add button or +), it inserts the phone in the side tags, (can be below or even within the input itself - just like this page when you insert the question subject tag).
But I couldn’t do the setChipData
, read the setTelefone
dynamically.
I have that code:
const handleDelete = (chipToDelete) => () => {
setChipData((chips) => chips.filter((chip) => chip.key !== chipToDelete.key));
};
const [chipData, setChipData] = React.useState([
{ key: 0, label: '(31) 9999-9999' },
{ key: 1, label: '(32) 9888-8888' },
]);
return (
<div className="register-container">
<div className="content">
<div className="input-group">
<InputMask
placeholder="Telefone"
value={telefone}
mask={["(99) 9999-9999", "(99) 9 9999-9999"]}
onChange={setTelefone}
/>
<Paper component="ul" className={classes.root}>
{chipData.map((data) => {
let icon;
return (
<li key={data.key}>
<Chip
icon={icon}
label={data.label}
onDelete={handleDelete(data)}
className={classes.chip}
/>
</li>
);
})}
</Paper>
</div>
</div>
</div>
);
}
Here’s the demo of Material ui, I just couldn’t get it to take input. https://codesandbox.io/s/93bfb?file=/demo.js