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

117
Visualizações
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 à 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