Best practice for partial data loading in dashboard with independent chart sections #14757
matthew-bl
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey guys, I need your help!
I'm developing an analytics dashboard in React Router v7 (Framework Mode) and I'm trying to figure out the best way to split queries on the same route - so I can reload only specific parts of the UI without refreshing everything.
Requirements
/key-metrics/:metric)My approach
Nested routes:
/key-metrics(layout) - fetches KPI cards, hasshouldRevalidate: falsefor:metricchanges/key-metrics/:metric(child) - fetches chart dataSeparate server functions:
kpi.queries.server.tsline-chart.queries.server.tsbar-chart.queries.server.tsmap.queries.server.tsResource routes + useFetcher for chart-specific updates:
useFetcher.load('/api/line-chart?...')→ skeleton only in Line ChartuseFetcher.load('/api/bar-chart?...')→ skeleton only in Bar ChartShared functions: Both the /key-metrics/:metric route loaders and the resource routes (
/api/*) would use the same query functions to avoid code duplication.Questions
Is this the correct pattern for React Router v7?
shouldRevalidateto prevent parent reloaduseFetcher+ resource routes for granular chart updatesShould I consider TanStack Query instead of useFetcher?
Is there a simpler/better pattern I'm missing?
Thanks! 🙏
Beta Was this translation helpful? Give feedback.
All reactions