From 53de9a1cddc526041ea39fd9201db363af924fd4 Mon Sep 17 00:00:00 2001 From: Alberto Defendi <1369-ahl-berto@users.noreply.gitlab.inf.unibz.it> Date: Wed, 23 Jun 2021 07:10:56 +0200 Subject: [PATCH] Polish return. --- src/components/Authorization/Authorization.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/components/Authorization/Authorization.tsx b/src/components/Authorization/Authorization.tsx index e532385..77a3956 100644 --- a/src/components/Authorization/Authorization.tsx +++ b/src/components/Authorization/Authorization.tsx @@ -31,11 +31,9 @@ export const withAuthorization = (allowedRoles: string[]) => < T extends WithAuthProps = WithAuthProps >( WrappedComponent: React.ComponentType<T>, -): FC<T> => { +): FC<T> => // Creating the inner component. The calculated Props type here is the where the magic happens. - const ComponentWithAuthorization: FC<T> = ( - props: Omit<T, keyof WithAuthProps>, - ) => { + (props: Omit<T, keyof WithAuthProps>) => { const [role, setRole, isLoading] = useRole(); const [isAuth] = useAuth(); console.log(`ROLE ${role} AUTH ${isAuth} LOADED ${isLoading}`); @@ -50,6 +48,3 @@ export const withAuthorization = (allowedRoles: string[]) => < <HandleIsAuth isAuth={!!isAuth} /> ); }; - - return ComponentWithAuthorization; -}; -- GitLab