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

100
Visualizações
rerender React JS

So i m trying to rerender a list by filtered values. The list is already rendered with all the values. I want to render it again with a dropdown of options. I get my values from a JSON locally.

[ { "brand": "toyota", "model": "corona", "cylinders": 4, "horsepower": 96, "origin": "Japan", "price": 40000 }, ... ]


export const FilterBrand = (props) => {
  const brands = props.list
    .map((vehicle) => vehicle.brand)
    .filter((value, index, vehicle) => vehicle.indexOf(value) === index);

  const handleChange = (e) => {
    // console.log(e.target.value);
  };
  return (
    <select onChange={(e) => props.handleChange(e.target.value)}>
      {brands.map((vehicle, key) => (
        <option key={key} value={key}>
          {vehicle}
        </option>
      ))}
    </select>
  );
}; here is my component



<div className="filter-brand">
 <FilterBrand
 list={list}
 handleChange={(value) => console.log(value)}
 />
</div here is my component imported in main app, JSON is also imported in main app and passed as props in my component.
How can I render it again based on the options from the dropdown?
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

use a state to store the 'results' to show then use a function or two to change 'results' based on the 'filter' selected. When a change in state occurs react will automatically re-render the view for you

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