mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-08 08:34:20 +02:00
return empty div instead of null when user do not have role for hydrate issue
This commit is contained in:
parent
089af3880a
commit
458df713ad
@ -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 />
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user