Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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>
}
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