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
In my application, users can navigate to /item/[itemCode], and SWR will fetch the data related to that item. In cases where the item does not exist, the API responds with an error.
To optimize this scenario, I've set shouldRetryOnError to false since it's impossible for the item to suddenly come into existence. However, even with error retries disabled, SWR attempts to automatically revalidate the data, for example, when switching between tabs. This automatic revalidation triggers another failed call when the item doesn't exist.
Ideally, I would like to revalidate the data only when the item does exist, and skip the revalidation attempts when the item is not found. Is there a recommended approach or workaround within SWR to achieve this behavior?
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
-
In my application, users can navigate to
/item/[itemCode]
, and SWR will fetch the data related to that item. In cases where the item does not exist, the API responds with an error.To optimize this scenario, I've set
shouldRetryOnError
to false since it's impossible for the item to suddenly come into existence. However, even with error retries disabled, SWR attempts to automatically revalidate the data, for example, when switching between tabs. This automatic revalidation triggers another failed call when the item doesn't exist.Ideally, I would like to revalidate the data only when the item does exist, and skip the revalidation attempts when the item is not found. Is there a recommended approach or workaround within SWR to achieve this behavior?
Beta Was this translation helpful? Give feedback.
All reactions