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

185
Vistas
React .map() won't update when .filter changes

I have a page with a search, you can filter the results with a range slider. I have an onChange event on the slider that should dynamically set a .filter param. I am passing that param to a chained .sort().filter(props.filter).map().

When I use the slider, it is changing the parameter that I'm passing through, but the .map() is not updating the results.

Any help greatly appreciated:

    let genderSpecificFilter = 'All';
    let rangeSpecificFilter = 'All'
    let sendFilteredDoctors = () => filterDoctors(genderSpecificFilter,rangeSpecificFilter);

    function changeRangeFilterParams() {
        rangeSpecificFilter = checkBoxDistanceMap[document.getElementById('range-miles').value];
        sendFilteredDoctors = filterDoctors(genderSpecificFilter,rangeSpecificFilter);
        console.log(rangeSpecificFilter)
    }
<PrintSearchResults
                                doctors={doctors} 
                                filters={sendFilteredDoctors}
                            />
import PrintDoctor from "./printdoctor";

function PrintSearchResults(props) {
    return (
        <div>
            {props.filters}
            <p className="text-xl text-gray-350">
                Total Results: 
                <span className="ml-3" id="total-results-num">
                    {props.doctors.results
                    .sort((a, b) => a.locations[0].distance - b.locations[0].distance)
                    .filter(props.filters).length}
                </span>
            </p>
            
            {props.doctors.results
            .sort((a, b) => a.locations[0].distance - b.locations[0].distance)
            .filter(props.filters)
            .map((doctor, key) => (
                <PrintDoctor 
                    image={doctor.image} 
                    url={doctor.url}
                    fullName={doctor.fullName} 
                    specialties={doctor.specialties} 
                    locations={doctor.locations}
                    gender={doctor.gender}
                    key={key}
                />
            ))}

        </div>
    );
}
export default PrintSearchResults

Edit: On change coming from here:

<input onChange={changeRangeFilterParams} type="range" min="1" max="6" className="slider" defaultValue="6" id="range-miles" />
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