Skip to content

fix: use event value directly in handleChange to fix search bug#1

Open
ImaginandoyCreando wants to merge 1 commit intoForis:mainfrom
ImaginandoyCreando:patch-1
Open

fix: use event value directly in handleChange to fix search bug#1
ImaginandoyCreando wants to merge 1 commit intoForis:mainfrom
ImaginandoyCreando:patch-1

Conversation

@ImaginandoyCreando
Copy link
Copy Markdown

Problema

La función handleChange usaba filterText del estado directamente
en el fetch, pero React no actualiza el estado de forma inmediata.
Esto causaba que cada búsqueda enviara el valor ANTERIOR a la API,
es decir, siempre iba un carácter atrasado.

Solución

Se extrae el valor del evento en una variable value antes de
llamar al fetch, y se usa esa variable en lugar de filterText.

Cambio

  • Antes: name=${filterText} → valor desactualizado
  • Después: const value = event.target.value + name=${value} → valor correcto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant