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

342
Vistas
React-autosuggest enhancements - how to filter + render images

I am using react auto-suggest and I want to enhance it, but the documentation hasn't helped me much. My suggestions are structured like this and I retrieve them from firebase (I fetch all the products etc.)

suggestions=[
{
name:"product name", 
brand:"brand name", 
img: an image url
}
]

The code works fine and I get suggestions, but for example if I have a product with a name consisting of 2 words for example, I only get the correct suggestion if I type in the first word. Here is the getSuggestions and getSuggestionValue functions:

const getSuggestions = value => {
    const inputValue = value.trim().toLowerCase();
    const inputLength = inputValue.length;
  
    return inputLength === 0 ? [] : searchProducts.filter(prod =>
      prod.name.toLowerCase().slice(0, inputLength) === inputValue || prod.brand.toLowerCase().slice(0, inputLength)===inputValue
    );
  };

  const getSuggestionValue = suggestion => suggestion.brand+"-"+suggestion.name;

Also, when rendering, I also want to display a little image, but the renderSuggestion doesn't work. Here is the function:

const renderSuggestion = suggestion => (
    <div style={{display:'flex', flexDirection:'row', width:'100px'}}>
      <img src={suggestion.img[0]} style={{width:'10px', height:'10px'}}/>
      <p>{suggestion.brand} - {suggestion.name}</p>
    </div>
  );

Also, the suggestions come with bullets like in an unordered list. Is there anyway I can change this?

A hint or anything would be very much appreciated. Thank you!

about 4 years ago · Juan Pablo Isaza
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