T
TanStack13mo ago
sensitive-blue

Minimizing re-renders caused by queries in the parent component of the application

Current tech stack is Static Nextjs application with a Go API and postgres db. In the parent component of the codebase I am trying to fix, there is a custom hook which makes an api call which provides information for the entire application I am working on. The hook takes in 9 arguments which have state information. Some of this information also comes from parameters in the URL. I am trying to mitigate rerenders, as any state change almost anywhere in the app causes cascading rerenders due to the hook. I'm hoping React Query could help, but I'm unsure what my best options are for restructuring this application. I imagine server actions would help, but I'd need a surer direction to go in if I want to restructure the whole application. I'm wondering if anyone can point me at a direction here.
1 Reply
sensitive-blue
sensitive-blueOP13mo ago
For reference, I understand that React Query will help with de-duplication and caching, but the number of state changes which are required either way is massive. The response from the API frequently changes as the application holds a map display, so the caching is likely not a huge benefit.

Did you find this page helpful?