You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The author of #1671 ran into the same issue and proposed requiring the deps argument, but I think it makes more sense to drop the default useCallback deps.
I currently have a use case where I ran into this with something like
While I could add the args to the deps array, it's clearer code if I could leave the deps array out and the function isn't memoized at all.
As a hacky workaround, I'm passing null to deps which then "works", but isn't the clearest code.
Besides making the default case more clear, it also means that the [] needs to be done explicitly, and since the React team has mentioned that an empty deps array is sus, that seems like a win to me.
The text was updated successfully, but these errors were encountered:
The author of #1671 ran into the same issue and proposed requiring the deps argument, but I think it makes more sense to drop the default useCallback deps.
I currently have a use case where I ran into this with something like
While I could add the args to the deps array, it's clearer code if I could leave the deps array out and the function isn't memoized at all.
As a hacky workaround, I'm passing
null
to deps which then "works", but isn't the clearest code.I think changing the default deps to be undefined or null would be the best solution here. https://github.com/streamich/react-use/blob/master/src/useAsyncFn.ts#L38
Besides making the default case more clear, it also means that the
[]
needs to be done explicitly, and since the React team has mentioned that an empty deps array is sus, that seems like a win to me.The text was updated successfully, but these errors were encountered: