T
TanStack10mo ago
probable-pink

Responsive master detail routes

How can we implement responsive master detail (https://v5.reactrouter.com/web/guides/philosophy/responsive-routes/) routes with file based routing. Currently, I have following files. posts -> index.tsx posts -> $id.tsx /posts route opens index.tsx loader that fetch data from /api/posts and render list of posts summary. Each summary has link that takes user to /posts/:id /posts/:id route opens $id.tsx loader that fetches data from /api/posts/:id and renders post detail. This is great for mobile screens. For larger screens, if user clicks on posts summary, instead of 'redirecting' to detail page, I want to show post detail on right side of post summary list. I cannot wrap my head around it with file based routing as routes dynamically change based on screen size. I tried with: posts -> route.tsx posts -> $id.tsx But it was triggering duplicate API calls and it didn't look clean to me. Any help is appreciated.
ReactRouterWebsite
React Router: Declarative Routing for React
Learn once, Route Anywhere
1 Reply
metropolitan-bronze
metropolitan-bronze10mo ago
hm I don't think this is possible in the router really. can't you handle this in the route component somehow?

Did you find this page helpful?