leerob / leerob.io

✨ My portfolio built with Next.js, Tailwind, and Vercel.

Home Page:https://leerob.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SWR fetching behavior

omaralsoudanii opened this issue · comments

@leerob
I am not sure if this is a bug or related to the browser console being opened somehow, on page visit /api/views/[slug] is triggered for every post (guess this is okay since the hook is used with each blog post in list view).

What is confusing is that if you click go to any article, the same requests (for the whole loaded list) are fired again, I can't confirm if this SWR gets refocused because the browser console or it actually fire all requests.

I changed with my code some SWR configs (binding to a key, get initial data etc..) and noticed that it kinda stopped requesting everything ‐ by kinda I mean it's random, also they return 304, is this from the API or SWR not actually calling the API by having stale time.

Check the below recording to see what I mean.

swr_fetcher.mp4

Hey, SWR author here! The recording seems broken and I can’t watch it. But from your description I guess it’s caused by re-focusing on the window when you click, where the focus was on the console.

Closing this as it seems to be working as expected 🙏