-
According to the type definition and implementation, the fetcher function seems to support a non-promise function.
Line 1 in a9c10f7
swr/test/use-swr-suspense.test.tsx Lines 81 to 95 in a9c10f7
Lines 779 to 785 in a9c10f7 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
In my understanding, swr can be used as a state managment library for various cases, not only for handling network requests. The Imagine we're building a todo list app, swr hooks can still be a great helper to access and cache states of todo items. // getTodoItems can be a function reading todos from local states
const {data:todoItems} = useSWR('todos', getTodoItems) here's another example in swr codebase https://github.com/vercel/swr/tree/master/examples/storage-tab-sync |
Beta Was this translation helpful? Give feedback.
In my understanding, swr can be used as a state managment library for various cases, not only for handling network requests. The
revalidate
action could mean "retrieve state from data source", which can be either sync or async.Imagine we're building a todo list app, swr hooks can still be a great helper to access and cache states of todo items.
here's another example in swr codebase https://github.com/vercel/swr/tree/master/examples/storage-tab-sync