Estoy usando reaccionar y quiero mapear un componente solo cuando todas mis condiciones sean verdaderas, pero hay 4 condiciones y no quiero usar declaraciones si anidadas
Intenté esto y funciona, pero creo que es feo y no es una buena práctica:
{posts.map((post, i) => { if ( post.author && post.story_title && post.story_url && post.created_at ) { return <Card key={i} post={post} />; } else { return null; }También probé esto y parece funcionar, pero no estoy seguro porque cuando registro la variable isValidPost obtengo una fecha y no un booleano falso o verdadero:
{posts.map((post, i) => { let isValidPost = post.author && post.story_title && post.story_url && post.created_at; console.log(isValidPost); if (isValidPost) { return <Card key={i} post={post} />; } else { return null; }¿Hay una mejor manera de hacer esta validación?