Next.js Discord

Discord Forum

Missing key prop error when I have it in my code

Unanswered
Gharial posted this in #help-forum
Open in Discord
GharialOP
So Whenever I am trying to make a build, I am facing this error -
Error: Missing "key" prop for element in iterator react/jsx-key

Now this is the only part of the component where I am mapping something and may need a key -
{playlists.map((playlist: Playlist) => (
                <div 
                key={playlist.id} 
                className='hover:bg-neutral-800'
                onClick={() => {
                  props.setGlobalPlaylistId(playlist.id);
                  props.setView('playlist');
                }}
                >
                  <ListItemType1  
                    image={playlist.images[0].url} 
                    title={playlist.name} 
                    creator={playlist.owner.display_name} 
                    isPlaylist={true}
                  />
                </div>
              ))
              }

I have the key attached to the div. I even tried using an Index but that gave me the same error.
I have also tried putting /* eslint-disable */ at the top of the file but that doesn't do anything either. And now I am super confused

1 Reply