handleFilter = key => { const selected = parseInt(key); if (selected === 3) { return this.setState({ eventsData }); } const statusMap = { 1: "complete", 2: "inProgress" }; const selectedStatus = statusMap[selected]; const filteredEvents = eventsData.filter( ({ status }) => status === selectedStatus ); this.setState({ eventsData: filteredEvents }); };
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