Skip to content

Commit

Permalink
Add error to useCurrentUser return
Browse files Browse the repository at this point in the history
  • Loading branch information
giovanisleite committed Jun 1, 2020
1 parent 9a1eedb commit 633b7f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/typeDeclarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface DeleteAccountState {
export interface CurrentUserState {
currentUser: any
validating: boolean
error?: string | null
}

export interface AuthFormState {
Expand Down
4 changes: 2 additions & 2 deletions src/useCurrentUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

0 comments on commit 633b7f3

Please sign in to comment.