jotaijs/jotai-tanstack-query

How to reset atom to loading state after reseting an error boundary

Ouverte

#32 ouverte le 26 avr. 2023

 (8 commentaires) (0 réaction) (0 personne assignée)TypeScript (19 forks)auto 404
help wanted

Métriques du dépôt

Stars
 (287 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

So far I've tried using the QueryErrorResetBoundary (like described here) and calling queryClient.invalidateQueries(...) manually when reseting the error boundary, but the outcome is as follows:

  • I shut down my server & reload
  • The query fetches, fails, component enters error state, gets caught in error boundary
  • I click the fallback "try again" button to reset the error boundary
  • The component immediately renders in an error state and fails again
  • The query refetches, but doesn't seem to update the atom
  • Even after clicking "try again" again the same happens

The error handling example you provide seems to work by changing the user state to a different view where the query doesn't fail. When navigating to the item that causes the error, it immediately fails again. How could we reset the query, so instead of failing the atom tries again and reenters the loading state?

Guide contributeur