DioxusLabs / DioxusLabs/dioxus
use_loader: loader.loading() is not reactive during background refetch in fullstack routing
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
**Problem**
In fullstack mode (`use_loader` + SSR + client-side routing), the loading indicator
`loader.loading()` may remain/stay `false` even while a real request is being executed
and the data is being updated.
This is especially noticeable when navigating back to a previously visited route:
- the request is actually triggered,
- the data is updated after some delay,
- but `loader.loading()` does not reflect the loading state.
Since there is no reliable loading indicator, **stale data remains visible on the screen**
during the request, while the UI has no way to indicate that the data is currently being refreshed.
Notably, if **any additional reactive signals** are present
(for example, a user-defined `Signal` that is updated when the request starts and finishes),
`loader.loading()` begins to behave as expected. This suggests that the issue is specifically related
to the **lack of reactive subscription** to the loading state, rather than incorrect request execution.
**Steps To Reproduce**
Steps to reproduce the behavior:
- Open the route `/bug/first` (SSR, Suspense works as expected)
- Navigate to `/bug/second` (client-side navigation, `loader.loading()` becomes `true`)
- Navigate back to `/bug/first`
- Observe that:
- the request is executed (visible via artificial delay and data update),
- the data is updated,
- but `loader.loading()` remains `false` for the entire duration of the request,
causing stale data to remain visible in the UI without any loading indication.
Minimal reproducible example:
https://github.com/nerjs/dioxus-bug-loader
**Expected behavior**
When navigating back and triggering a background data refresh, one of the following
should occur:
- `loader.loading()` reactively reflects the loading state,
- the component transitions back to `Pending` and activates
`SuspenseBoundary.fallback`,
- or there is an explicit and reactive API to detect background loading.
In all cases, the UI should be able to correctly indicate that the currently displayed
data is temporarily stale and is being refreshed.
**Environment:**
- Dioxus version: 0.7.2
- Rust version: 1.91.1 (ed61e7d7e 2025-11-07)
- OS info: Linux 6.8.0-87-generic x86_64 GNU/Linux
- App platform: web (fullstack)
**Questionnaire**
I would like to fix this and I have a solution.
---
**Additional notes / Possible directions**
Below are possible approaches for discussion (not as a requirement):
1. Use the reactive resource state (`resource.state()`) instead of
`resource.finished()` inside `loader.loading()`, so the loading status
becomes reactive and correctly reflects background refreshes.
2. Set `loader_state = Pending` when a background reload starts, which would
re-activate `SuspenseBoundary.fallback` and make it useful for client-side
navigation in fullstack applications.
3. A combination of both approaches.
If the current behavior is considered intentional, it might be worth at least
explicitly documenting that `loader.loading()` is not a reactive indicator of
background loading and should not be relied upon for UI state.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.