Replies: 6 comments
-
I faced with the same issue, found out that this problem is somehow related to the proxy. Reproduce: https://stackblitz.com/edit/github-n9s1u9-tnwckd?file=src/routes/index.tsx |
Beta Was this translation helpful? Give feedback.
-
This one is pretty core question so I moved it here. But the answer isn't actually too obvious. What is happening is we do the refetch all route data under a Transition and it therefore does it all in the background. The problem is that being under a transition the state can't actually update until its committed. Before doing this calling Refetch would cause the whole app to fallback to the Suspense boundary which is not what you want. You might be thinking well we should make an exception for resources. However, I think that depends on perspective. Is this refetch happening on the current timeline or an alternate (from a concurrent rendering standpoint). Should the current timeline understand the loading state or only the one about to render. Like if you use Transitions themselves have the means to know if they are in flight so if we exposed that somehow that might be a better solution. But I wanted to bring this over because the first question is most important. Whether resource state should be exempt from Transitions. |
Beta Was this translation helpful? Give feedback.
-
@ryansolid from your answer, I understood that I can use the useTransition for the pending indicator, did I get it right? Also for me, useTransition works like magic( why, for example, clicking on the refetchRouter data button triggers my useTransition, where can I get information about how it all works under the hood? (there is not much information about transitions in the solid documentation) reproduce: https://stackblitz.com/edit/github-n9s1u9-tnwckd?file=src/routes/index.tsx |
Beta Was this translation helpful? Give feedback.
-
Using My only issue here is that this solution was not at all obvious, I had no clue that I'm guessing anybody trying to show a loading state while running EDIT: Oh, after reading @4c656f's last comment I just realized I don't even have to wrap my |
Beta Was this translation helpful? Give feedback.
-
Yeah the thing is this ties into a the global transition and it might not always be accurate. I'm thinking of how to best expose this in a way that applies to just the routing or the specific action. The router has no knowledge of the data being requested so this doesn't belong in the router package. Solid's tracking might be too general, so the only logical place is in SolidStart perhaps. But I don't like that answer, so I need to think about it. The refetchRouteData does return a promise but we probably want these things reactive. It wouidn't be hard to wrap them, but then I wonder if it should be a more general mechanism like |
Beta Was this translation helpful? Give feedback.
-
Yeah given the OP found a solution and we can back that. I'm going to move this into discussions. This is more of a future design consideration. |
Beta Was this translation helpful? Give feedback.
-
I'm making a small toy dashboard, and I've defined this route data:
This works beautifully with
<Suspense>
andrenderStream
to display a loading spinner while the data is fetched on page load.However, this being a dashboard, I want to refresh the data now and then, so I'm using
refetchRouteData
.This works, however I want to be able to display some indicator that the data is currently being refetched. From the docs, it sounds like I should be able to use
resource.state
for this. However, it doesn't seem likerefetchRouteData
actually updates the state of each resource like it should.To test, I added a
createEffect
to log the state of each resource:This logs:
So it shows "pending" as the page opens, then "ready" as each resource finishes loading. After that, every time I press the refetch button, it just logs "ready" again, as the resources finish loading.
Shouldn't the state change to "refreshing" while the data is being refetched?
Beta Was this translation helpful? Give feedback.
All reactions