-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: useSWRAggregator #2018
base: main
Are you sure you want to change the base?
WIP: useSWRAggregator #2018
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit be97fb9:
|
bc3e15c
to
747dd8f
Compare
chroe: update
747dd8f
to
bb3ea77
Compare
any plan on crossing the finish line? look forward to using this feature |
Would also like to utilize this! We have a workaround that involves looping thru the list of service calls, creating a component for each which uses the useSwr() hook, then utilizes a callback/reducer to send the data back to the parent which aggregates everything. Our particular use case is we have data that's loading in different components throughout the page, but then also have a component that needs to know the status of which panels have had their data loaded already. |
This pr is trying to explore a possible solution for #1041 and #1988
Motivation
In most of time, if users want to render a list of useSWR hooks, they could do something like this.
But this pattern has some problems
useSWRAggregator
Design
Usage
Problems
useSWR
internally, it wouldn't share config withuseSWRAggregator
and needs extra code to configuseSWR
config individually
Demo
https://codesandbox.io/s/useswraggregator-je1dxf