-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useAsyncFn - deps parameter should be required #1671
Comments
Current workaround:
Augmenting a module declaration with a function adds an overload, so it's necessary to ban the signatures you don't want. |
Hi! @react-hookz/web, the new library by one of For those interested, there's an official migration guide for migrating from react-use to @react-hookz/web. Hope this helps! |
The second parameter in the
useAsyncFn
is a dependency array and it is currently optional with a default value of[]
, which is passed on touseCallback
internally. An empty array means that the callback function is memoized and never updated.This is unexpected because it doesn't match how native React hooks work, e.g. in
useMemo
an undefined dependency array causes the value to be recomputed on every render, and inuseEffect
an undefined array causes the effect to fire on every render. Both of these are different from an empty array.I think it would be safer to make the second parameter required, which would match how
useCallback
works. This is a breaking change so maybe not so easy to do, but hopefully it could still be fixed at some point.The text was updated successfully, but these errors were encountered: