Proposal: Add Opt-Out for Fetcher Persistence in Non-Standard Use Cases #9937
lifeiscontent
started this conversation in
Proposals
Replies: 2 comments 5 replies
-
|
Would it be possible to create a minimal reproduction of the UX you're describing so we can be sure we fully understand the use-case? That way we can play around with it and see what the options are. |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
@brophdawg11 here you go: https://github.com/lifeiscontent/fetcher-persist-proposal-example please check the readme for instructions and explanation of the problem |
Beta Was this translation helpful? Give feedback.
4 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.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
Before the introduction of
v3_fetcherPersist, I was utilizing akeyfor afetcherto determine whichfetcherwas actively running. My use case, however, deviates from the typical Remix request loop, which operates as follows:loaderruns.loaderDatabecomes accessible in the route component.actionruns.actionDataorfetcher.datacan be accessed within the route component.The Use Case
In my scenario, there's a risk that our customers could exceed the limit of query parameters. To address this, we use a combination of
loaderDataandactionData, structured as:Here, when the fetcher runs, its data takes precedence over
loaderData, and we useFormDatato update the currentdata.The Problem
Previously, before
v3_fetcherPersistexisted, I could do something like:This allowed me to use the same fetcher in several sub-components that needed access to the specific fetcher matching the key. However, with the current implementation, I must first create a fetcher without the key and then pass that fetcher to all sub-components needing access. This approach makes the code much harder to write and maintain.
Additionally, the issue arises when a
keyis used inuseFetcher. On the first render, this page can potentially cache and display stale data from the fetcher because it is persisted. This is particularly problematic in scenarios where data needs to be fresh and updated immediately.Proposed Solution
It would be beneficial to allow developers to opt out of fetcher persistence for specific use cases. Although using
URLSearchParamsis the recommended approach, there are limitations due to the maximum length of a query string and the potential security concerns of submitting sensitive data via the URL.I propose reintroducing the
persistfunctionality from the original RFC, with the ability to passpersist: falseto opt out of the fetcher’s persistence when needed.Beta Was this translation helpful? Give feedback.
All reactions