React-query tip: You don't have to mess with error handling on each query
React-query tip: You don't have to mess with error handling on each query.
Instead, you can automatically fallback to the nearest error boundary if any query fails with one global setting.
How? Enable useErrorBoundary globally when declaring your QueryClient.
#react

Oh, and this technique couples nicely with React Router.
You can declare an errorElement on a parent route. Then all child routes automatically have a default error fallback.
And you can provide a custom errorElement for child routes when desired.
Quite slick.
