Access outlet context within the data loader #13994
Closed
henrychu04
started this conversation in
Proposals
Replies: 1 comment
-
We can't pass React context values to loaders/actions because they run before React has even rendered. What you really want here is middleware so you can gather the data before any loaders run and then make them available to loaders via the middleware/loader |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
Would it be possible to access outlet context from within the data loader function? The data loader is able to access url parameters, but in my use case, not all the ids that I need to use are located in the url.
I have three cases:
funds/:fundId/scenarios/:scenarioId
funds/:fundId
scenarios/:scenarioId
Each fund has a scenario id, and each scenario has a fund id. I need both ids to make all the necessary requests in my components. For the second and third case, I am extracting out the corresponding fund or scenario id from the opposing object. Then, I am passing down both of these ids through the outlet context so that all child components are able to easily retrieve these ids without needing to reparse the url and perform the same logic to get both fund/scenario ids.
Since the urls in the second and third case have missing ids and will require additional requests to get all the necessary ids, would it be possible for the loader to access the outlet context as well? That way, I can take advantage of the loader function and efficiently make my requests.
Beta Was this translation helpful? Give feedback.
All reactions