Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

340
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!