startTransition with updateTag?
Unanswered
African Slender-snouted Crocodil… posted this in #help-forum
African Slender-snouted CrocodileOP
Is there any way to show a transition while the page is refreshing as a result of calling updateTag in a server function? The updateTag API is synchronous so wrapping my server function in startTransition only runs a transition for the actual server function, not the updateTag.
Use case would be showing a loading spinner or similar next to the element that is expected to refresh.
Use case would be showing a loading spinner or similar next to the element that is expected to refresh.
3 Replies
Greek Shepherd
Good to know: updateTag immediately expires the cached data for the specified tag. The next request will wait to fetch fresh data rather than serving stale content from the cache, ensuring users see their changes immediately.African Slender-snouted CrocodileOP
Yeah, so I suspect what that means is the answer is "no", but it does feel like it's a relatively common pattern to want to display an indicator that some data is stale?
Greek Shepherd
No it means that calling updateTag doesnt result in the page being refreshed. U can use the refresh function from next/cache for that.
Use refresh to refresh the users client router (person who called the action)
Use updateTag to expire a cache so that the next time anybody requests the same route, the server will fetch new data
Use refresh to refresh the users client router (person who called the action)
Use updateTag to expire a cache so that the next time anybody requests the same route, the server will fetch new data