create user Board component and withUserConnected hoc

This commit is contained in:
memeriau
2022-01-30 00:15:23 +01:00
parent b842174ebe
commit 4800e12d9f
3 changed files with 29 additions and 6 deletions

View 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