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

Wrong href when throwing redirect in React Strict Mode #882

Closed
universse opened this issue Dec 26, 2023 · 4 comments
Closed

Wrong href when throwing redirect in React Strict Mode #882

universse opened this issue Dec 26, 2023 · 4 comments

Comments

@universse
Copy link

universse commented Dec 26, 2023

Describe the bug

For the kitchen sink example, after turning on React Strict Mode and entering /profile route, location.href becomes /login?redirect=%2Flogin%3Fredirect%3D%252Fprofile. Should be /login?redirect=%2Fprofile. It's also reflected in the URL bar.

Side question, is it recommended to use beforeLoad to redirect from /login if user is already logged in instead of useLayoutEffect?

Your Example Website or App

https://tanstack.com/router/v1/docs/examples/react/kitchen-sink-react-query-file-based

Steps to Reproduce the Bug or Issue

See description

Expected behavior

See description

Screenshots or Videos

No response

Platform

NA

Additional context

No response

@schiller-manuel
Copy link
Contributor

schiller-manuel commented Dec 26, 2023

cannot reproduce here (I only removed the // to enable react strict mode): codesandbox

@universse
Copy link
Author

universse commented Dec 26, 2023

image

the wrong URL shows up when you enter /profile route via the address bar and not link click. it should just be /login?redirect=%2Fprofile. my bad, could have been clearer.

@V1RE
Copy link
Contributor

V1RE commented Dec 26, 2023

Could this be related to #861?

@schiller-manuel
Copy link
Contributor

solved with 1.0.1
see codesandbox

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

4 participants