skip to Main Content

Reactjs – This should prevent duplicate items in my list, but it doesnt. Any idea why?

export default function Track({ data, setPlaylist, playlist }) { function handleAdd(song) { console.log(song.id); if (!playlist === song) { setPlaylist((playlist) => [...playlist, song]); } } return ( <div className="tracks"> {data.map((song) => ( <div className="box" key={song.id}> <h2>{song.name}</h2> <h3>by {song.artist}</h3> <p> from {song.album}</p>…

VIEW QUESTION
Back To Top
Search