-
As I'm learning more about Next.js, I decided to run two examples, one using Apollo Client (2.6) and one with the SWR hook. From what I understood reading the docs, if I want to use static generation (so the user doesn't have to wait for rendering) I have to call But then I tried SWR, which in the docs says you can use it if you want to render everything except the data that needs to be fetched, so you get static rendering without having to wait for the blocking data. But as I created the example every time I reloaded the page, I could see the "Loading..." in just a blank page being returned, my expectation was to see everything else (all the components, navigation, etc) except the data. Is there something wrong I'm doing here? Is my implementation incorrect? All I want is to be able to render everything quickly (static generation) and fetch all the small pieces of data in the client side without having a blank screen or flashing. So far with Apollo seems to be working fine, but not so much with SWR. Below is the same Done with Apollo:
Done with SWR:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The reason your entire application is showing loading, and not just the data you're fetching, is because of this line.
If you'd like to only render the list of beers client side, you should only apply the loading state to that piece of the returned JSX.
If you're using SWR, you can remove |
Beta Was this translation helpful? Give feedback.
The reason your entire application is showing loading, and not just the data you're fetching, is because of this line.
If you'd like to only render the list of beers client side, you should only apply the loading state to that piece of the returned JSX.
If you're using SWR, you can remove
getStaticProps
since you're doing client-si…