Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

343
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda