Skip to content

Commit

Permalink
useAsync - no longer needlessly cache promise instance
Browse files Browse the repository at this point in the history
  • Loading branch information
LankyMoose committed Apr 12, 2024
1 parent 86f6368 commit d31243a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions packages/lib/src/hooks/useAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ export function useAsync<T>(
data: null as T | null,
error: null as any | null,
loading: true as boolean,
promise: undefined as Promise<T> | undefined,
},
({ hook, oldHook, update }) => {
if (depsRequireChange(deps, oldHook?.deps)) {
hook.data = null
hook.loading = true
hook.error = null
hook.deps = deps
hook.promise = func()
hook.promise
func()
.then((data: T) => {
if (!depsRequireChange(deps, hook.deps)) {
hook.data = data
Expand Down

0 comments on commit d31243a

Please sign in to comment.