From 633b7f3167140298cd7bc9259fd3a079822f98b2 Mon Sep 17 00:00:00 2001 From: Giovani Date: Mon, 1 Jun 2020 17:18:51 -0300 Subject: [PATCH] Add error to useCurrentUser return --- src/typeDeclarations.ts | 1 + src/useCurrentUser.tsx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/typeDeclarations.ts b/src/typeDeclarations.ts index 17e6be5..21ab876 100644 --- a/src/typeDeclarations.ts +++ b/src/typeDeclarations.ts @@ -46,6 +46,7 @@ export interface DeleteAccountState { export interface CurrentUserState { currentUser: any validating: boolean + error?: string | null } export interface AuthFormState { diff --git a/src/useCurrentUser.tsx b/src/useCurrentUser.tsx index d2f0549..8fc3e32 100644 --- a/src/useCurrentUser.tsx +++ b/src/useCurrentUser.tsx @@ -16,7 +16,7 @@ function useCurrentUser( 'currentUser', ) as InstanceOptions - const [{ info: currentUser, fetchingInfo }, actions] = useCroods(opts) + const [{ info: currentUser, fetchingInfo, infoError }, actions] = useCroods(opts) const initFetch = useCallback(() => { const headers = getHeaders(opts) @@ -32,7 +32,7 @@ function useCurrentUser( // eslint-disable-next-line }, [currentUser]) - return [{ currentUser, validating: !!fetchingInfo }, actions.setInfo] + return [{ currentUser, validating: !!fetchingInfo, error: infoError }, actions.setInfo] } export default useCurrentUser