Archived
Hotfix: withoutAuth + ajustements UserContext
This commit is contained in:
1 parent
5d048f3010
commit
ca0c77a522
7 files changed
+75
-37
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { useContext } from 'react';
|
||||
import { UserContext } from '../contexts/UserContext';
|
||||
import redirect from '../utils/redirect';
|
||||
|
||||
const withoutAuth = (WrappedComponent) => {
|
||||
|
||||
const Component = (props) => {
|
||||
|
||||
const { isAuth, user } = useContext(UserContext);
|
||||
|
||||
if (isAuth) return redirect({}, `/profile/${user.name}`);
|
||||
|
||||
return <WrappedComponent { ...props } />;
|
||||
}
|
||||
|
||||
return Component;
|
||||
}
|
||||
|
||||
export default withoutAuth;
|
||||
Reference in new issue
Block a user