found
found copied to clipboard
Is it possible to render the loading page depending on the server's response speed?
Hi @taion I can't solve the above question and I'm trying to get your help.
When a loading page is set through a render function, the loading page is always shown regardless of the server's response speed.
However, if the response from the server is very fast, it is thought that rendering the loading page is an unnecessary act, and it is an unpleasant UX.
For example, if response from the server before 200ms after querying, show the next page without rendering the loading page, and if response passed 200ms, show the loading page.
It's possible in principle, but it's not really straightforward (and it shows the limitations of trying to do this without suspense/concurrent mode).
Are you using Found Relay here?
The rough approach here is that we'd want to modify the resolver such that, instead of immediately yielding the first set of pending elements, that we'd race against a timeout, and only yield them if the "final" elements don't show up in time.
In Found, https://github.com/4Catalyzer/found/blob/dbd0177ba36f76b7d6fe0de0b40d3e9415eb7503/src/resolver.js#L45-L47 In Found Relay, https://github.com/relay-tools/found-relay/blob/master/src/Resolver.js#L81-L83