Created
July 2, 2021 15:32
-
-
Save IgorDePaula/6c4e308db9fb0e44ef83541ae05b7a6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {createContext, useState} from "react"; | |
export const AuthContext = createContext() | |
export const AuthProvider = ({children}) => { | |
const [user, setUser] = useState({}) | |
return <AuthContext.Provider value={[user, setUser]}> | |
{children} | |
</AuthContext.Provider> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Auth} from 'aws-amplify'; | |
import {useContext, useEffect} from 'react' | |
import {useState} from 'react'; | |
import {useForm} from "react-hook-form"; | |
import {useRouter} from "next/router"; | |
import {XCircleIcon} from "@heroicons/react/solid"; | |
import {AuthContext} from "../src/AuthContext"; | |
export default function Login() { | |
const {register, handleSubmit} = useForm(); | |
const router = useRouter() | |
const [user, setUser] = useContext(AuthContext) | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment