Isolated Component Data loading #3946
discoverlance-com
started this conversation in
Proposals
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.
-
Currently remix nested routing supports isolation of data by allowing teams for example, to handle loading of main
posts.tsxpage data separately from a nested route likeposts/new.tsx.This though does not really help when one wants to load data in a completely isolated component system. Example, for my posts main route:
In this case, data loading is not really isolated as this
posts.tsxfile still handles data loading for the navigation and the footer component without much regard to separation of data. The footer team needs to update thisposts.tsxroute loader and same with the navigation team if they wanted to make changes. If we wanted them to load their data separately, we'd have to make them a nested route for example and it will be/posts/footerthat will render our footer. This of course is not the behaviour we want.What I propose is instead we have a directory like
sub-pagesin the remixappdirectory. This directory can then hold actualremix-likepages. So examplenavigation.tsxand export a default function that returns jsx.These pages will only be capable of handling data loading and actions for starters. We can then import these pages into a page in the
routesdirectory like theposts.tsxfile.The loaders in the
sub-pageswill load it's data in parallel to the data loaded in the actual remix page route it's imported in. All components or pages in this directory will not and cannot be rendered as a remix page but can be added as a component to a page in theroutesdirectory.This will really approach a truly isolated layout of routes/components that can handle it's own data loading so if data is needed in the footer, the footer can handle it's own loader without that data needing to be included in the data loaded in the
posts.tsxor the route file that imports it.Example:
Beta Was this translation helpful? Give feedback.
All reactions