Skip to content

Commit

Permalink
fix(frontend): flashing content on useAsync reload
Browse files Browse the repository at this point in the history
  • Loading branch information
apricote committed Feb 21, 2023
1 parent ac0f9ff commit e298282
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions frontend/src/hooks/use-async.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ export const useAsync: UseAsync = <T extends any>(
const execute = useCallback(() => {
startTransition(() => {
setPending(true);
setValue(initialValue);
setError(null);
});

return asyncFunction()
.then((response) => startTransition(() => setValue(response)))
.catch((err) => startTransition(() => setError(err)))
.finally(() => startTransition(() => setPending(false)));
}, [asyncFunction, initialValue]);
}, [asyncFunction]);

// Call execute if we want to fire it right away.
// Otherwise execute can be called later, such as
Expand Down

0 comments on commit e298282

Please sign in to comment.