There are quite a few questions and answers on this topic out there already, but I don't seem to get my JSX to render properly from a condtion within a map() function.
The function I am calling from my render() function looks like this:
renderAudiobookChoice(audioBookChoice) {
if (audioBookChoice === "all") {
return this.state.audiobooks.map(audiobook => (
<AudiobookDetail key={audiobook.id} audiobook={audiobook} />
));
}
if (audioBookChoice === "poetry") {
this.state.audiobooks.map(audiobook => {
return audiobook.text_type === 2 ? (
<AudiobookDetail key={audiobook.id} audiobook={audiobook} />
) : null;
});
}
}
So if my audioBookChoice = 'all', the AudiobookDetails are rendered properly. But if I audioBookChoice = 'poetry', it does not render anything to the screen anymore.
My linter gives me the follwoing warning: "Expected to return a value at the end of arrow function. (array-callback-return)". This is confusing me, as I am under the impression that I should be returning something following my terniary operator.
Any help would be much appreciated.