ConsoleTVs / sswr

🔥 Svelte stale while revalidate (SWR) data fetching strategy
MIT License
234 stars 11 forks source link

Is there a way to display placeholder data? #14

Closed frederikhors closed 3 years ago

frederikhors commented 3 years ago

I would like to have something like https://sveltequery.vercel.app/guides/placeholder-query-data.

This is useful when you have for example list/detail navigation.

Example: list of users > click on one of them > load from cache (using the list key) > show data > fetch in background for the first time the user data (with a /user/1) key.

What do you think?

frederikhors commented 3 years ago

I think swr has the same called initialData: https://swr.vercel.app/docs/with-nextjs, right?

frederikhors commented 3 years ago

I'll try it in a few moments...

ConsoleTVs commented 3 years ago

initialData is already supported. I will explore if I am really interested in this but I qould rather like to use the data and error return values to determine if you should show some preview data

frederikhors commented 3 years ago

It works as expected. Thanks.