Proper way of using multiple SWR hooks with same initialData #568
Unanswered
vladfulgeanu
asked this question in
General
Replies: 3 comments 2 replies
-
@vladfulgeanu, did you manage to resolve this? Could you please share your solution? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Just asked a similar question, been wondering this myself. Only year later and I still can't find an answer 😅 |
Beta Was this translation helpful? Give feedback.
0 replies
-
https://swr.vercel.app/docs/advanced/cache will be the recommended way in the future (we will add more examples soon), please try it out! |
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.
-
Let's say I have a main component that uses SSR and then passes that data to useSWR's
initialData
What happens if
dataFromServer
is very complex and needs to be used in many other child components down the tree, how shouldinitialData
be initialized to those useSWRs as well? Given thatinitialData
is per hook, they will have a split second of loading state and the advantage of usinginitialData
is nulled. Is passingdataFromServer
through props a good practice?Should a react reducer/state be used in this case to store
dataFromServer
and passed around with contexts?Basically how should useSWR along with SSR or SSG be used when having complex data structures without resorting to somehting like redux?
How can the initialData from the server be used across all components that need it and also have changes (mutation) of data visible everywhere?
Beta Was this translation helpful? Give feedback.
All reactions