You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Will it be possible to include the key used to get data in the SWRResponse together with the data?
The case is:
We have a setup where we use 2 useSWR hooks where #2 is dependent on the data from #1 and the key used for #1. This is used to show a list of data and some totals that are fetched asynchronously. To avoid flickering, we use the keepPreviousData and onLoadingSlow to keep the old data for a small amount of time before displaying a spinner.
But, useSWR #2 will start fetching data when key used for #1 is changes as this is used for #2 also. And when #1 has fetched the data, #2 will fetch the correct data depending on both data and key from #1.
Had to use data from onLoadingSlow instead of result from useSWR to be able to have data and the corresponding key in sync.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Will it be possible to include the
key
used to get data in theSWRResponse
together with thedata
?The case is:
We have a setup where we use 2 useSWR hooks where #2 is dependent on the data from #1 and the
key
used for #1. This is used to show a list of data and some totals that are fetched asynchronously. To avoid flickering, we use thekeepPreviousData
andonLoadingSlow
to keep the old data for a small amount of time before displaying a spinner.But, useSWR #2 will start fetching data when
key
used for #1 is changes as this is used for #2 also. And when #1 has fetched the data, #2 will fetch the correct data depending on both data andkey
from #1.Had to use data from onLoadingSlow instead of result from useSWR to be able to have data and the corresponding key in sync.
Beta Was this translation helpful? Give feedback.
All reactions