I'm getting this message error, this never happened before... I'm comparing to a code and it's exactly like that and it's not showing any error.
My Code:
interface AuthState { token: string; user: User; } interface SignInCredentials { login: string; senha: string; } interface User { id: number; name: string; login: string; } interface AuthContextData { user: User; token: string; signIn(credentials: SignInCredentials): Promise<void>; signOut(): void; } const AuthContext = createContext<AuthContextData>({} as AuthContextData); const AuthProvider: React.FC = ({ children }) => { const [data, setData] = useState<AuthState>(() => { const token = localStorage.getItem('@Ponteflix:token'); const user = localStorage.getItem('@Ponteflix:user'); if (token && user) { return { token, user: JSON.parse(user) }; } return {} as AuthState; });
Can soomeone help me?
Img:
To my knowledge, should the AuthContextData should be the return type?
AuthContextData
const AuthContext = createContext<AuthContextData>(): AuthContextData;
2.1m questions
2.1m answers
60 comments
57.0k users