use-async-function
use-async-function copied to clipboard
Feature Req: add dependency array similar to useMemo
Proposed Syntax:
const loadUsers = useAsyncFunction( () => fetch('/users'), [x,y,z]);
where the array of [x,y,z] is used, either directly with useMemo, or indirectly with the same basic behavior, to reset the Fulfilled state and force the function to be called again.
My use case is that the user can change the server, negating all cached values, but my wrapping API hides that detail so the async hook would probably not notice that it happened and remain Fulfilled.