Skip to content

Instantly share code, notes, and snippets.

View rushil1999's full-sized avatar

Rushil Shah rushil1999

  • San Jose
View GitHub Profile
import React, {useContext} from 'react'
import {AuthContext} from '../contexts/AuthContextProvider';
import { Navigate, useLocation } from 'react-router-dom';
const PrivatePath = ({children}) => {
//Used to store the current location, so that it can be redirected back to this component after login
const location = useLocation()
//Reads the context value
const authContext = useContext(AuthContext);
import React, {useContext, useState} from 'react';
import { AuthContext } from '../contexts/AuthContextProvider';
import { useNavigate, useLocation } from "react-router-dom";
import Button from '@mui/material/Button'
import Paper from '@mui/material/Paper';
import TextField from '@mui/material/TextField';
const Login = () => {
const navigate = useNavigate();
import { BrowserRouter, Routes, Route} from 'react-router-dom';
import AuthContext from './contexts/AuthContextProvider.js'
import PrivatePath from './components/PrivatePath.js';
import Login from './components/Login.js';
import Navigation from './components/Navigation.js';
import PrivateComponent from './components/PrivateComponent.js';
import PublicComponent from './components/PublicComponent.js';
import LandingPage from './components/LandingPage.js';
function App() {
import React,{useState, createContext} from 'react';
//Creating a context using 'createContext'
export const AuthContext = createContext(null);
const AuthContextProvider = ({children}) =>{
//Boolean value that would simply indicate whether User is signed in or nor
const [authState, setAuthState] = useState(false);
//Object to store other user details like name, email, etc