Feature request: Lazy fetcher ?
See original GitHub issueImagine a Cascader
component, which has two Select
components, in which the second one depends on the selected item from the first component.
In this case, could useSWR
supports lazy fetcher by returning a refetch
function which can be run later ?
const { data, error, refetch } = useSWR(key, { lazy: true })
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Feature request: Lazy fetcher ? · Issue #176 · vercel/swr - GitHub
In this case, could useSWR supports lazy fetcher by returning a refetch function which can be run later ? const { data, error,...
Read more >5 ways to initialize lazy associations and when to use them
Using fetch joins in JPQL statements can require a huge number of queries, which will make it ... Named entity graphs are a...
Read more >Eager/Lazy Loading In Hibernate - Baeldung
It can result in fetching and storing a lot of data, irrespective of the need for it. We can use the following method...
Read more >Lazy fetching in Spring JPA - different behaviour within cron ...
The error tell you that you're trying to fetch a lazy association, ... of short-lived Session and bypasses a lot of features that...
Read more >The best way to lazy load entity attributes using JPA and ...
This configuration alone is not sufficient because Hibernate requires bytecode instrumentation to intercept the attribute access request and ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
To me this does not really resolve the issue. I know that technically this addresses the feature request, but it doesn’t seem like an officially supported solution to me. All I see in the docs for mutate is references to mutating data (which makes sense), not lazy fetching.
The fact that it can be used for lazy fetching seems more like an implementation detail to me than an offically supported part of the API. I’d be hesistant to use this in production as I wouldn’t feel comfortable relying on this not breaking in a patch/minor bump.
Could we reopen, and ideally implement a lazy flag? Would that be in scope for this lib?
EDIT: see my gist below with a better solution
I agree that a
lazy
option would be nice, but for now, here is my solution for auseLazyRequest
hook: