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?
3 Replies
conscious-sapphireOP•2y 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•2y ago
do you have staleTime set ?
conscious-sapphireOP•2y ago
No but that seems to help, thank you!