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

227
Vistas
How to make API call on slider stops moving?

I have a range slider. When I move the slider I am getting the updated values. Say if slider range is 1 to 50, on slider move I will get 1 to 50 values and 50 api calls will be made. How to avoid this and make a single api call when the slider stops moving.

My requirement:
when I stop moving the slider, I want to make api call with last updated value. Below my code: import React, { Component } from ‘react’

class SearchFilters extends Component {

  constructor(props) {
    super(props)
  }

  handleChange(e) {
    let updatedValue = e.target.value;
    Console.log(‘updatedValue’, updatedValue)
    //make api call here
  }

  Render(){
    Return(
      <div className='range-input'>
      <input type='range' id="r0"min='0’ max=‘50' onChange={(value) => this.handleChange(value)} />
      </div>
    )
  }
}
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

For that purpose I would use react-rangeslider

It has callback onChangeComplete which you can use to achieve what you want.

I think that's the easiest way.

Here is how your code would look like :

import React, { Component } from "react";
import Slider from "react-rangeslider";
import "react-rangeslider/lib/index.css";
class SearchFilters extends Component {
  constructor(props, context) {
    super(props, context);
    this.state = {
      value: 0
    };
  }
 
  handleChange = value => {
    this.setState({
      value: value
    });
  };

  handleChangeComplete = () => {
    //here you will make your api call
    console.log("Change event completed");
  };
  render() {
    const { value } = this.state;
    return (
      <div>
        <Slider
          min={0}
          max={50}
          value={value}
          onChange={this.handleChange}
          onChangeComplete={this.handleChangeComplete}
        />
        <div className="value">{value}</div>
      </div>
    );
  }
}
export default SearchFilters;
about 4 years ago · Santiago Trujillo Denunciar
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