I have a function that chooses which icon to display based on when memType is passed through:
const renderAvatar = (memType) => {
if ((memType = "Music")) {
return <MusicIcon style= />
} else if ((memType = "Movie")) {
return <MovieIcon style= />
} else if ((memType = "TVShow")) {
return <TVIcon style= />
} else if ((memType = "Game")) {
return <GameIcon style= />
} else if ((memType = "Event")) {
return <EventIcon style= />
}
}
However, it is only returning the icon of whichever condition is at the top (the MusicIcon in the above example). For example, it would only display the MovieIcon if that was the first condition:
const renderAvatar = (memType) => {
return <MovieIcon style= />
} else if ((memType = "TVShow")) {
if ((memType = "Music")) {
return <MusicIcon style= />
} else if ((memType = "Movie")) {
return <TVIcon style= />
} else if ((memType = "Game")) {
return <GameIcon style= />
} else if ((memType = "Event")) {
return <EventIcon style= />
}
}
I have checked that the memType data being passed through is correct and it is and can't work out what I'm doing wrong.
Aucun commentaire:
Enregistrer un commentaire