-
Notifications
You must be signed in to change notification settings - Fork 13
Fix blank screen flash on client-side redirect #1125
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
const { orgName, projectName } = useAllParams('orgName') | ||
|
||
const { data } = useApiQuery('projectList', { orgName, limit: 20 }) | ||
const { data } = useApiQuery('projectList', { orgName, limit: 10 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the same as the other projectList
requests for accurate deduping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like we need a less flaky way to ensure these stay in sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wholeheartedly agree, I hate it. I have a sneaky idea: if we take the limit
param off of the request in QueryTable
(unless it's specified through a prop, maybe) then we can rely on the default page size practically everywhere and we avoid syncing it by not using the limit
param almost anywhere.
On second read, I think I understand what is going on. The key is the
So: a real nav (push) to
Rather than a |
Aaaaaand of course I'm not done. While the above situation works as desired (not making a history entry for the route we're skipping over), it doesn't work when you hit the route directly. So, for example if you go to |
Reverted in 1fda0f3 until I figure this out. |
Closes #1123
redirect
is new in RR 6.4 (it comes from Remix) and it is now the recommended way to do these kinds of redirects, as opposed to rendering<Navigate to="my-path" />
. There are some things I don't understand aboutredirect
's behavior that I want to note; otherwise this wouldn't be worth a whole PR.The phenomena
element={<Navigate to="my-path" />}
, returning a redirect from a loader does not cause it to hang out on the route while the next loader runs. That's why it fixes Blank screen flash on client-side redirects #1123, which is the point of this PR.https://google.com
, it will briefly flash a client-side error because that doesn't match any routes you have defined, and then it will actually navigate to google.com. I think this is a bug in RR. It's hard to imagine why you would ever want that to happen.redirect
. I did not see a way to make it do a replace instead of a push, which is what we need. It appears to do areplace
by default.Why might this be
First of all,
redirect
just returns a 302Response
with the passed-in location in theLocation
header. (source)The next thing to know is how RR handles a redirect returned from a loader. In
callLoaderOrAction
, a 302 response is converted into this "result" (source):Finally, in
handleLoaders
, the comment says redirects are handled as a replace (source) but this is only true if thereplace: true
is passed tohandleLoaders
, and as far as I can tell (I went through in the debugger) it is not. Then, of course, in practice it is a replace, but I can't figure out why.So this works for us, but I don't understand why. I will try to find out from the devs. I have a feeling this is only accidentally right, and I want it to be right on purpose.