Skip to content

Commit

Permalink
fix: update state on isConnected state change (#823)
Browse files Browse the repository at this point in the history
  • Loading branch information
luizstacio authored Aug 2, 2023
1 parent 4e08bc0 commit 60218b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .changeset/tender-emus-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
4 changes: 3 additions & 1 deletion packages/docs/src/hooks/useLoading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { useState, useCallback } from 'react';

import { useFuel } from './useFuel';
import { useIsConnected } from './useIsConnected';

export function useLoading<T extends (...args: any) => Promise<void>>(
callback: T,
Expand All @@ -10,6 +11,7 @@ export function useLoading<T extends (...args: any) => Promise<void>>(
const [fuel] = useFuel();
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>();
const [isConnected] = useIsConnected();
const execute = useCallback(
async (...args: any) => {
setError(null);
Expand All @@ -22,7 +24,7 @@ export function useLoading<T extends (...args: any) => Promise<void>>(
setLoading(false);
});
},
[fuel, ...deps]
[fuel, isConnected, ...deps]
);

return [execute as T, loading, error] as const;
Expand Down

0 comments on commit 60218b5

Please sign in to comment.