jotaijs/jotai-tanstack-query

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

開放

#32 建立於 2023年4月26日

 (8 則留言) (0 個反應) (0 位負責人)TypeScript (19 個分叉)auto 404
help wanted

倉庫指標

星標
 (287 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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?

貢獻者指南