T
TanStack2y ago
conscious-sapphire

Unnecessary requests being made

I have a dashboard with view A & view B. View A uses a select list component to display my projects. View B uses the same select list component, as well as a table component to display the projects. Both components individually fetch their data using the same function. (project.ts:9) The issue: On view A, the select list component makes a request to projects to retrieve them, all fine. When navigating to view B however, I see 4 new requests for projects in the network tab (see image). They are unnecessary as I already retrieved the projects in view A, how to prevent this from happening?
No description
3 Replies
conscious-sapphire
conscious-sapphireOP2y ago
TLDR: 1. Two components use the same query to retrieve data, how to only retrieve data once instead of twice? 2. When using a component in multiple views in Next.js, how to prevent the component from re-fetching on each view change?
equal-aqua
equal-aqua2y ago
do you have staleTime set ?
conscious-sapphire
conscious-sapphireOP2y ago
No but that seems to help, thank you!

Did you find this page helpful?