Replies: 2 comments 1 reply
-
|
show a codesandbox reproduction please |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
use function TError() {
const navigate = useNavigate();
const { reset } = useQueryErrorResetBoundary();
return (
<>
<h1>Error</h1>
<button
onClick={() => {
reset();
navigate(".", { replace: true });
}}
>
retry
</button>
</>
);
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I recently updated the react-router and rewrote the router config as an RouteObject using createBrowserRouter. Along with this, I changed the approach to catching errors on the page and instead of a QueryErrorResetBoundary above the
Outletcomponent, I wrote a component that is passed in theerrorElementto the root object of the router. In theerrorElementcomponent I use the useQueryErrorResetBoundary hook and call thereset()function to reset query errors, but after that the page is not re-rendered and queries are not re-fetch.In the documentation I found an example for react-router v6.4+ https://tanstack.com/query/v5/docs/framework/react/examples/react-router with RouteObject interface, but in this example on the error page in
errorElementtheuseQueryErrorResetBoundaryis not used.Could you please suggest how to properly reset errors inside
errorElementwith usinguseQueryErrorResetBoundaryfor the current version of react-router?Beta Was this translation helpful? Give feedback.
All reactions