Fix blank screen flash on client-side redirect#1125
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.
This should be the same as the other projectList requests for accurate deduping.
There was a problem hiding this comment.
Feels like we need a less flaky way to ensure these stay in sync.
There was a problem hiding this comment.
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
redirectis 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 areplaceby default.Why might this be
First of all,
redirectjust returns a 302Responsewith the passed-in location in theLocationheader. (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: trueis 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.