AuthProvider.js

import { useState } from 'react'
import { AuthContext } from './AuthContext'

export const AuthProvider = ({ children }) => {
  let [authData, setAuthData] = useState(null)

  let onLogin = (data) => {
    setAuthData(data)
  }

  let onLogout = () => {
    setAuthData(null)
  }

  let value = { authData, onLogin, onLogout }

  return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>
}