Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

I'm trying to delete an object from an array and the response I get is that the data is undefined in react.js ?

By M.K. Verma · 2 May 2022

I'm trying to delete an object from an array and the response I get is that the data is undefined in react.js ?

Try this

           <User
              name={album.name}
              band={album.band}
              city={album.city}
              id={album.id}               <----- Add this line
              genresId={
                genres &&
                genres.map((g) => {
                  if (g.id === album.genresId) {
                    return g.name;
                  }
                  return "";
                })
              }
              onDelete={onDelete}
            />