update
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
} from 'react'
|
||||
import * as Auth from 'aws-amplify/auth'
|
||||
|
||||
interface AuthContextType {
|
||||
export type AuthContextType = {
|
||||
authUser: Auth.FetchUserAttributesOutput | null
|
||||
signIn: ({
|
||||
username,
|
||||
@@ -21,8 +21,14 @@ interface AuthContextType {
|
||||
|
||||
const AuthContext = createContext<AuthContextType | null>(null)
|
||||
|
||||
export function useAuth() {
|
||||
return useContext(AuthContext)
|
||||
export function useAuth(): AuthContextType {
|
||||
const ctx = useContext(AuthContext)
|
||||
|
||||
if (!ctx) {
|
||||
throw new Error('useAuth must be used within an AuthProvider')
|
||||
}
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
||||
export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
|
||||
Reference in New Issue
Block a user