Example from: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes
A Pen by Sourabh Bagrecha on CodePen.
| import { Button } from '@mui/material' | |
| import { useContext } from 'react'; | |
| import { UserContext } from '../contexts/user.context'; | |
| export default function Home() { | |
| const { logOutUser } = useContext(UserContext); | |
| // This function is called when the user clicks the "Logout" button. | |
| const logOut = async () => { | |
| try { |
| import { Button, TextField } from "@mui/material"; | |
| import { useContext, useState } from "react"; | |
| import { Link, useLocation, useNavigate } from "react-router-dom"; | |
| import { UserContext } from "../contexts/user.context"; | |
| const Signup = () => { | |
| const navigate = useNavigate(); | |
| const location = useLocation(); | |
| // As explained in the Login page. |
| import { Button, TextField } from "@mui/material"; | |
| import { useContext, useEffect, useState } from "react"; | |
| import { Link, useLocation, useNavigate } from "react-router-dom"; | |
| import { UserContext } from "../contexts/user.context"; | |
| const Login = () => { | |
| const navigate = useNavigate(); | |
| const location = useLocation(); | |
| // We are consuming our user-management context to |
| import { useContext } from "react"; | |
| import { Navigate, Outlet, useLocation } from "react-router-dom"; | |
| import { UserContext } from "../contexts/user.context"; | |
| const PrivateRoute = (props) => { | |
| // Fetching the user from the user context. | |
| const { user } = useContext(UserContext); | |
| const location = useLocation(); |
| import { createContext, useState } from "react"; | |
| import { App, Credentials } from "realm-web"; | |
| import { APP_ID } from "../realm/constants"; | |
| // Creating a Realm App Instance | |
| const app = new App(APP_ID); | |
| // Creating a user context to manage and access all the user related functions | |
| // across different component and pages. | |
| export const UserContext = createContext(); |