Closed henricasanova closed 2 years ago
auth: bool returning true / false depending on if user is logged in or not
data: the content to be hidden
content: the type of content being hidden, passed as a string (e.g. "simulator", "practice questions", etc...)
Import:
import SigninCheck from '../../../components/signin_check'
To include at beginning of class / component (check if user is logged in):
const [auth, setAuth] = useState("false")
useEffect(() => {
setAuth(localStorage.getItem("login"))
})
Two ways to use component:
<SigninCheck data={[
<>
<x
...
/>
<y
...
/>
<z
...
/>
</>
]} auth={auth} content="practice questions"></SigninCheck>
<SigninCheck data={[
<x
...
/>,
<y
...
/>,
<z
...
/>
]} auth={auth} content="practice questions"></SigninCheck>
Used throughout the whole site successfully.
Implement a simple "hide if not logged on" component.