Skip to content

Instantly share code, notes, and snippets.

View diurivj's full-sized avatar

Diego Vazquez diurivj

View GitHub Profile
@EduVencovsky
EduVencovsky / Auth.jsx
Last active February 20, 2024 03:28
Private Routes with Auth using react-router and Context API
import React, { useState, useEffect } from 'react'
import PropTypes from 'prop-types'
import { checkIsAuthenticated, authSignUp, authLogin, authLogout } from '../../services/auth'
export const AuthContext = React.createContext({})
export default function Auth({ children }) {
const [isAuthenticated, setIsAuthenticated] = useState(false)
const [isLoading, setIsLoading] = useState(true)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>bliss</title>
<link rel="stylesheet" href="styles.css"/>