-
Notifications
You must be signed in to change notification settings - Fork 115
Closed
Description
A use-case one might attempt is:
const [debouncedAddress] = useDebounce({
address1,
address2,
country,
city,
state,
zip,
}, 1500)
useEffect(() => {
// do API call to update address on server
}, [
debouncedAddress.address1
debouncedAddress.address2
debouncedAddress.country,
debouncedAddress.city,
debouncedAddress.state,
debouncedAddress.zip,
])
...such that the form is auto-saved if the user has not typed in the last 1.5 seconds.
But in JS {} !== {}
is true
.
Suggesting the user use a hash function would be best. Otherwise, the above code example will trigger a re-render every 1500 ms. This should be accompanied w/ a note about the exhaustive-deps eslint rule.
leohxj and bombillazo
Metadata
Metadata
Assignees
Labels
No labels