Skip to content

Commit

Permalink
Setting the data before setting the loading state.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriztiaan committed Oct 8, 2024
1 parent 6e65811 commit c55a8c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/react/src/hooks/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ export const useQuery = <T = any>(
previousQueryRef.current = { sqlStatement, memoizedParams };

const handleResult = (result: T[]) => {
setData(result);
setIsLoading(false);
setIsFetching(false);
setData(result);
setError(undefined);
};

const handleError = (e: Error) => {
setData([]);
setIsLoading(false);
setIsFetching(false);
setData([]);
const wrappedError = new Error('PowerSync failed to fetch data: ' + e.message);
wrappedError.cause = e;
setError(wrappedError);
Expand Down

0 comments on commit c55a8c4

Please sign in to comment.