Repository navigation
@rangojs/router 0.33.2
Fixed: router.refresh() keeps the page's location state (#1369)
Before. useRouter().refresh(), and the refresh another tab's server
action triggers, replaced the history entry with one that held only the
state the server set on the refreshed response. Every useLocationState
reader lost its value in the commit that showed the refreshed page (a
"load more" list dropped the pages it carried), and Back then Forward onto
the entry restored nothing.
Now. A refresh keeps the entry's location state, typed slots and plain
state, on the entry and in every reader, with the same value identity.
State the server sets on the refreshed response merges over it. A flash value
already shown stays on screen until the next navigation and is not written
back to the entry, so Back/Forward and a reload do not show it again. A
refresh of an open intercept still renders the full page, now with the
entry's location state.
Fixed: a remounted useLoader shows its own route's data, not an earlier page's refresh (#1370)
Before. After a load() (or a useRefreshLoaders() refresh) of a loader
registered on the route, the refreshed value stayed in the client's shared
store, and a reader that mounted later showed it instead of the data its own
navigation brought: on
another page with the same loader, on a new visit to the refreshed page, and
after passing through a page without the loader. A reader that stayed
mounted across a navigation drew the refresh for a frame before the new
route data, and a load() still in flight when the user left landed on the
next page, with its spinner and its error.
Now. A refreshed value belongs to the route data of the readers on screen
when load() was called. A reader whose route data is other data (a new
page, a new visit, a navigation or action that brought new data) shows that
data from its first frame, and its isLoading, error and throwOnError
ignore a refresh requested for other data. Readers of the same route data
still converge on the refresh, and Back onto a refreshed page from the
history cache shows the refresh again.
renderRoute now answers useLoader().load() and refresh-group refreshes
from the loader values the test gives (the render seeds, or
router.respondToLoads({ loaders })), through the testing kit's
@vitejs/plugin-rsc/browser alias: a test no longer mocks that module or
stubs fetch to drive a refresh.