Swr: use swr with redux actions?

Created on 3 Mar 2020  路  2Comments  路  Source: vercel/swr

Hey there team, I am looking at this library at a high level so forgive me if the answer is obvious.
I am currently a project I work on uses redux actions to make calls to the api
Somthing like this: https://redux.js.org/advanced/async-actions/#async-action-creators

Is it possible with swr in its current form to use that action in the component to do the api call through swr?

Most helpful comment

You could make your fetcher (the second arg of useSWR) dispatch that action, but then you will need to wait for the data to be fetched and return it, not that every time SWR will revalidate the data it will dispatch the action again.

All 2 comments

You could make your fetcher (the second arg of useSWR) dispatch that action, but then you will need to wait for the data to be fetched and return it, not that every time SWR will revalidate the data it will dispatch the action again.

yeah the "auto-refresh" is a desirable outcome in some places, I see there is polling as well as re-validate strategies thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

polc picture polc  路  3Comments

needcaffeine picture needcaffeine  路  3Comments

bcomnes picture bcomnes  路  3Comments

sergiodxa picture sergiodxa  路  4Comments

bywo picture bywo  路  4Comments