Replies: 1 comment 1 reply
-
|
I think the example is wrong, as you noticed, the POST request the triggers the action and then followed by a separate GET request, each request has its own router context instance making it impossible to share a value between them. However, this is true if the POST request was also a document request, in which case the same POST triggers the loaders, allowing the sharing of the router context instance. I think the example needs to be updated to mention that only works for document requests, cc @brookslybrand |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
According to the document Sharing Context Between action and loader, the context value set in the action phase can be used in the loader.
I assumed that the request in the action phase and the request in the revalidation phase were separate, and thus the context would be independent for each. Is that not the case? How is this possible? (My apologies if this question sounds strange, as I'm new to this topic.)
I followed the example in the document, but the loader only contains the default value instead of the value set in the action. Did I do something wrong? Repro: https://stackblitz.com/edit/github-165puddz?file=app%2Froutes%2Fhome.tsx
Is there any point in setting the context value within the loader/action instead of the middleware?
Beta Was this translation helpful? Give feedback.
All reactions