mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-11 13:56:29 +02:00
create user Board component and withUserConnected hoc
This commit is contained in:
12
src/utils/withUserConnected.tsx
Normal file
12
src/utils/withUserConnected.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import React from "react"
|
||||
import { useSelector } from "react-redux"
|
||||
import { isUserConnected } from "../store/auth"
|
||||
|
||||
function withUserConnected<T>(Component: React.ComponentType<T>) {
|
||||
return (props: T): JSX.Element | null => {
|
||||
const connected = useSelector(isUserConnected)
|
||||
return connected ? <Component {...props} /> : null
|
||||
}
|
||||
}
|
||||
|
||||
export default withUserConnected
|
Reference in New Issue
Block a user