I have this function where I have this piece of code, but it does not return anything, just leave blank
mostrarPostsNoValidos() {
if(this.state.posts.length > 0) {
this.state.posts.map((post, key) => {
if(post.validado === "0"){
return (
<a href={`/post/${post.id}/${post.slug}`} key={key}>
<div className="card post">
<div className="card-body">
{post.titulo}
</div>
</div>
</a>
);
}
});
} else {
return <h3>No hay posts que mostrar aún</h3>
}
}
returnstatement is returning frommap's callback function. Your outer functionmostrarPostsNoValidosdoesn't return anything ififcondition is equal totrue. Just addreturnon the third line beforemapinvocation. Although, I should mention thatmapis not the perfect suit for your case. More likereduceor you'll have to wrapmapwithinfilter.