const [inputValue, setInputValue] = useState('');
const [list, setList]= useState([]);
handleAddIntemOnList(){
// create a new item as object to be added to the list array
const newItem = {
name: inputValue,
addedAt: new Date().toLocaleTimeString("pt-br", {
hour: '2-digit',
minute: '2-digit'
})
}
// save into the list state
setList(prevState => [...prevState, newItem])
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter