Skip to content
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

Avoid removing navigate from route loader #3844

Open
blitzbohne opened this issue Mar 24, 2025 · 4 comments
Open

Avoid removing navigate from route loader #3844

blitzbohne opened this issue Mar 24, 2025 · 4 comments

Comments

@blitzbohne
Copy link

Which project does this relate to?

Router

Describe the bug

Currently the "navigate" property is marked as deprecated on the loader and it is advised to use throw redirect() instead. However I think this is a bug because there's a hug difference --> when we throw, we can not return loaded date from a root route while with the navigate property we get exactly this, we can navigate to a sub route after having loaded some data and return the actually loaded data so I think we need both features.

Your Example Website or App

https://stackoverflow.com/help/mcve

Steps to Reproduce the Bug or Issue

See the navigate property of the loader properties marked as deprecated

Expected behavior

Should not be marked deprecated and not be removed because it serves a completely different purpose than the throw redirect()

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: Latest

Additional context

No response

@schiller-manuel
Copy link
Contributor

please provide a complete minimal example of what you need this for. ideally fork one of the existing stackblitz examples

@blitzbohne
Copy link
Author

Hello @schiller-manuel I understand the need for samples but I don't think building a sample here is helpful.

The issue of throwing instead of being able to use navigate() in loader means we can NOT load data AND redirect but instead it would redirect only AFTER having loaded the data then it would load the same data again. Currently we use the navigate() prop and it works perfectly.

@schiller-manuel
Copy link
Contributor

still would like to see how this is being used

@blitzbohne
Copy link
Author

We're basically using root routes with sub routes. The root route loads the main data and supplies it via react context to is sub routes to avoid loading for every route. shouldReload:false is set on the root to do that only once with subsequent nested routing. However, the data loaded by the root defines which nested view we need to redirect to initially. Now if we'd throw it redirects but the data is loaded again eventhough it already existed. Using navigate prop we avoid throwing in the loader and can return its data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants