tRPCttRPC
Powered by
CasperLeerinkC
tRPC•17mo ago•
1 reply
CasperLeerink

Keep old data when changing trpc procedure inputs

Hi! I was wondering if anyone has a best practice for preventing a flash of no data when changing inputs for a certain trpc procedure using tanstack query. My usecase is a leaflet map where the data it fetches changes when changing the zoom or position of the map. But I still want to show the old data when I am panning the map for example.

I am currently using something like this where
navigate
navigate
triggers new inputs for the query.

const newSearchParams = {
      ...searchParams,
      bounds: newBounds,
    };
    utils.listing.getCoordinates.setData(newSearchParams, () => {
      return geoListings.data;
    });
    navigate({
      search: newSearchParams,
    });
const newSearchParams = {
      ...searchParams,
      bounds: newBounds,
    };
    utils.listing.getCoordinates.setData(newSearchParams, () => {
      return geoListings.data;
    });
    navigate({
      search: newSearchParams,
    });

Its working but I thought maybe there is a better way?
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Multiple Inputs on TRPC Procedure?
jackhammer8234Jjackhammer8234 / ❓-help
3y ago
TRPC Dynamic Procedure URL
Rasel HossainRRasel Hossain / ❓-help
2y ago
Get tRPC procedure latency?
ferdyFferdy / ❓-help
3y ago
Finding the Unused TRPC procedure...
0xtz00xtz / ❓-help
11mo ago