Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
Search Page using React - Need a "No results found" message

I am working with the following code. It is a movie search page. It works fine but when I put the name of a movie that does not exist, it shows me a blank page (thanks to the [] in line 8). I would like it to show me a "No results found" message. Can someone help me with the code? I am working with React in the frontend part of a project.

import React from 'react'
import Card from './Card'

const CardList = ({ results }) => {

    let data = [];
    if(results.data) {
        data = results.data.Search || [];
    }


  return (
    <section className='container'>

    <div className='row justify-content-center'> 
        
            {data.map((item) => (
                <Card key={item.imdbID} movie={item}/>
            ))}
        
    </div>
    </section>

  )
}

export default CardList
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can just add a

{
data.length!=0 ? 
data.map((item) => (
                <Card key={item.imdbID} movie={item}/>
            )) 
:
<div>No Results Found!</div> // here you could pass any component to show no results found message
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda