4 ms·
I saw `useDebounce` and thought "what the hell does debounce have anything to do with react render cycle?". When I check the code, `useDebounce` does... I don't
by nsonha 3y ago
I saw `useDebounce` and thought "what the hell does debounce have anything to do with react render cycle?". When I check the code, `useDebounce` does... I don't even know what it does, delayed set state?
https://github.com/uidotdev/usehooks/blob/380e83fa267157832e9a312b8dd9847e0e6a0f65/index.js#L225 https://github.com/uidotdev/usehooks/blob/380e83fa267157832e...
- emi2k01 3y agoIf you have state that changes too quickly (like the value of an input field), then you can use `useDebounce` to derive a state that only changes every `n` milliseconds.