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

116
Vistas
use of lodash debounce function

I am using a debounce function in my react native project. It gets triggered after user enters 3 characters but it is triggering after 2 sec instead of the delay i assigned to it.

  constructor() {
    this.init()
    this.hitSearchApi = debounce(() => {
      log('inside if is called debounce')
      this.getStudentTableData(() => this.updateFetchingStatus(true))
      this.updateSearchLoaderStatus(false)
      this.updateFetchingStatus(false)
    }, 100)
  }

I had created my debounce function inside the store constructor like this.

  @action
  onChangeSearchText = (searchText) => {

    if (get(searchText, 'length', 0) > 2) {
      log('inside search text if condition')
      this.updateSearchLoaderStatus(true)
      this.hitSearchApi.cancel()
      // this.updateSearchLoaderStatus(true)
      log('before hit search api')
      this.hitSearchApi()
      // fetch student list on search basis
    } else if (get(searchText, 'length') === 0) {
      this.setStudentListData({})
      this.updateFetchingStatus(true)
      this.resetSearchData()
    }

    this.searchText = searchText
  }

This is my onChange text triggered, which is getting called on textinput onChange event. Please help me out in this. What am I doing wrong here?

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