Estoy usando una función de rebote en mi proyecto nativo de reacción . Se activa después de que el usuario ingresa 3 caracteres, pero se activa después de 2 segundos en lugar del retraso i le asigné.
constructor() { this.init() this.hitSearchApi = debounce(() => { log('inside if is called debounce') this.getStudentTableData(() => this.updateFetchingStatus(true)) this.updateSearchLoaderStatus(false) this.updateFetchingStatus(false) }, 100) }Creé mi función de rebote dentro del constructor de la tienda de esta manera.
@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 } Este es mi texto onChange activado, que se llama en el evento textinput onChange . Por favor, ayúdame en esto. ¿Qué estoy haciendo mal aquí?