-
|
Hi, first of all, thank you for this amazing library. I have a home page which displays a list of sites. When you click on a site, it takes you to the individual site page. https://codesandbox.io/s/pensive-flower-lt235 I have two hooks I tried the Expectation is, when I fetch a list of sites, cache should be updated with entries for individual sites with ids, and when I navigate to the individual site page, data should be fetched from the cache and shouldn't make a network request. Any help appreciated, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
|
your code with initialData looks correct, I'm just not seeing anything because the sandbox requests data from can you maybe update the example to be runnable? |
Beta Was this translation helpful? Give feedback.
-
|
you have a very simple problem: your id is once a number, and once a string. your which doesn't find anything. It's a number in the cache, but a string when it comes from the url. TypeScript can help here ;) |
Beta Was this translation helpful? Give feedback.
-
|
Interesting discussion 👀 Working with TanStack Query often feels like managing a living system—data is constantly evolving, being cached, refreshed, and synchronized automatically. In a way, it reminds me of “tipos de flor de loto”. Different types of lotus flowers grow in changing environments but still maintain balance and beauty. Similarly, different query patterns (caching, invalidation, refetching) adapt to different states while keeping the app stable and predictable. Sometimes the key isn’t forcing one rigid pattern, but choosing the right “type” for the situation—just like selecting the right lotus for the right environment |
Beta Was this translation helpful? Give feedback.
you have a very simple problem: your id is once a number, and once a string. your
findfunction does:which doesn't find anything. It's a number in the cache, but a string when it comes from the url. TypeScript can help here ;)