T
TanStack14mo ago
sensitive-blue

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.'); } };
1 Reply
national-gold
national-gold14mo ago
This is not enough information to figure out the issue. Please create a minimal/simple reproduction of issue. Also, make sure that you aren't trying to access hooks/components, that are reliant on being wrapped in the <RouterProvider>

Did you find this page helpful?