Skip to content

useNavigate().navigate throws an error in the browser console when called #12984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DiRover opened this issue Feb 9, 2025 · 1 comment
Closed
Labels

Comments

@DiRover
Copy link

DiRover commented Feb 9, 2025

I'm using React Router as a...

library

Reproduction

I have created a simple application with three components for demonstration problem
https://github.com/DiRover/RR7-navigate-error.git

System Info

MacOS
Chrome
react 19
react-router 7.1.5
vite 6.1.0

Used Package Manager

pnpm

Expected Behavior

There should be no error in the browser console

Actual Behavior

There should be no error in the browser console when executing the navigate method.

Error in the browser console:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'result')

Image

I don’t understand what is causing this error, I only noticed that it occurs when SecondComponent has a loader in the route tree.

@DiRover DiRover added the bug label Feb 9, 2025
@timdorr
Copy link
Member

timdorr commented Feb 11, 2025

You should return plain objects from your loaders. Remove the calls to data and the error will go away.

@timdorr timdorr closed this as completed Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants