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

188
Views
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
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!