Medium
In a React application, you're building a dynamic list of thousands of clickable items. Each item needs to track when it's clicked. Which implementation would be most performance-efficient and why?
1function ItemList() {2 const [items] = useState(generateThousandItems());34 const handleItemClick = (event) => {5 const itemId = event.target.dataset.itemId;6 // Process item click7 };89 return (10 <div className="item-container" onClick={handleItemClick}>11 {items.map(item => (12 <div13 key={item.id}14 className="item"15 data-item-id={item.id}16 >17 {item.content}18 </div>19 ))}20 </div>21 );22}