mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-10 21:46:27 +02:00
return empty div instead of null when user do not have role for hydrate issue
This commit is contained in:
@@ -3,9 +3,9 @@ import { useSelector } from "react-redux"
|
||||
import { selectUserRoles } from "../store/auth"
|
||||
|
||||
function withUserRole<T>(requiredRole: string, Component: React.ComponentType<T>) {
|
||||
return (props: T): JSX.Element | null => {
|
||||
return (props: T): JSX.Element => {
|
||||
const roles = useSelector(selectUserRoles)
|
||||
return roles.includes(requiredRole) ? <Component {...props} /> : null
|
||||
return roles.includes(requiredRole) ? <Component {...props} /> : <div />
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user