The React example in the HTTP Requests documentation shows:
function search(e) {
setData('query', e.target.value)
get('/api/search', {
onSuccess: (response) => {
console.log(response)
},
})
}
Since setData is a React state setter, calling get() immediately after sends the previous state value rather than the updated one. This causes the search query to always be one character behind what the user typed.
Steps to reproduce:
Use the useHttp hook as shown in the docs
Type "abc" into the input
Observe that the first request sends "", the second sends "a", the third sends "ab"
The React example in the HTTP Requests documentation shows:
Since setData is a React state setter, calling get() immediately after sends the previous state value rather than the updated one. This causes the search query to always be one character behind what the user typed.
Steps to reproduce:
Use the useHttp hook as shown in the docs
Type "abc" into the input
Observe that the first request sends "", the second sends "a", the third sends "ab"