TanStackT
TanStack2y ago
2 replies
urgent-maroon

Help with @tanstack/react-router Error using useNAvigate

TypeError: Cannot read properties of null (reading 'navigate')
at @tanstack_react-router.js?v=1303dc0b:2914:21
at login (AuthContext.tsx:58:13)
at async handleSubmit (login.tsx:39:5)


import { useNavigate } from '@tanstack/react-router';

// ... other imports and code

const login = async (email: string, password: string) => {
try {
// Login code...
if (navigate) {
await navigate({ to: '/' });
} else {
console.error('Navigate function is not available.');
}
} catch (error) {
console.error(error);
toast.error('An error occurred during login. Please check your credentials.');
}
};
Was this page helpful?