Skip to content

Commit

Permalink
feat: fix cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
lewtakm committed Feb 25, 2021
1 parent c39a4dd commit 30da259
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/providers/auth/useCognitoUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ const mapCognitoUser = (user: any): CognitoUser | undefined => {
}

if (user) {
// eslint-disable-next-line no-console
console.log(
console.warn(
'aws-amplify returned a CognitoUser. However, it has been skipped, because it lacks required attributes',
user,
);
Expand Down Expand Up @@ -85,7 +84,6 @@ export const useCognitoUser = (): {
}
};

// eslint-disable-next-line @typescript-eslint/no-misused-promises
Hub.listen('auth', ({ payload: { event } }) => {
switch (event) {
case 'signIn':
Expand All @@ -101,8 +99,16 @@ export const useCognitoUser = (): {

return () => {
isMountedRef.current = false;
// eslint-disable-next-line @typescript-eslint/no-misused-promises
Hub.remove('auth', updateUser);
Hub.remove('auth', ({ payload: { event } }) => {
switch (event) {
case 'signIn':
case 'cognitoHostedUI':
updateUser();
break;
default:
break;
}
});
};
}, [isMountedRef]);

Expand Down

0 comments on commit 30da259

Please sign in to comment.