You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created a custom hook like the docs suggest here: https://swr.vercel.app/docs/getting-started#make-it-reusable. But since I'm using this with Next.js, I'm wondering how to correctly set up my custom hook so that initialData is also reused when I use my hook within components.
For example, something where I'm showing a user Avatar in a Nav component:
Fetch User data in getServerSide props, pass to page
Pass initial User data into hook from within the page function
Use hook/initialData in Nav component, but no initialData is passed in here
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I've created a custom hook like the docs suggest here: https://swr.vercel.app/docs/getting-started#make-it-reusable. But since I'm using this with Next.js, I'm wondering how to correctly set up my custom hook so that
initialData
is also reused when I use my hook within components.For example, something where I'm showing a user Avatar in a Nav component:
User
data in getServerSide props, pass to pageUser
data into hook from within the page functionBeta Was this translation helpful? Give feedback.
All reactions