useErrorBoundary option works in useQueries?
Discussed in https://github.com/tannerlinsley/react-query/discussions/2355
Originally posted by luizeboli June 8, 2021 Hello guys, I have this hook:
export const useOptions = () => {
return useQueries([
{
queryKey: 'groups',
queryFn: () => axios({ method: 'GET', url: '/groups' }),
useErrorBoundary: true,
},
{
queryKey: 'types',
queryFn: () => axios({ method: 'GET', url: '/types' }),
useErrorBoundary: true,
},
{
queryKey: 'sourcedTypes',
queryFn: () => axios({ method: 'GET', url: '/sourcedTypes' }),
useErrorBoundary: true,
},
])
}
The component that consumes this hook is wrapped by a ErrorBoundary, but it doesn't throw while using useQueries. It just works with useQuery.
The only change needed to work correctly is replace useQueries by useQuery.
Is this an expected behavior? I didn't find it in docs
I have the same problem but it does not work yet: https://github.com/tannerlinsley/react-query/pull/2109
Related: https://github.com/tannerlinsley/react-query/issues/1523
does useErrorBoundary work in useQueries without suspense? Also, if you open an issue, please create a codesandbox example that reproduces the issue, thanks.
does
useErrorBoundarywork inuseQuerieswithout suspense? Also, if you open an issue, please create a codesandbox example that reproduces the issue, thanks.
It works in useQuery without suspense so maybe its supposed to.
I'm not trying to report a bug its just a question, thats why I did not created a Sandbox. I asked in discussions but got no replies
It works in useQuery without suspense so maybe its supposed to.
That wasn’t the question though. Does it work in useQueries without suspense? Trying to narrow down if it’s useQueries+suspense related, because for that we already have an issue and yes, that doesn’t work yet
Yes useQueries works perfectly without suspense! I only missed an option for refetchInterval in useQueries
okay, I've made a reproduction: https://codesandbox.io/s/holy-darkness-qy5tw?file=/src/index.js
even with suspense: false, useQueries does not correctly work with useErrorBoundary.
However, I think that the open PR that tries to solve #1523 will also fix this issue, see:
https://github.com/tannerlinsley/react-query/pull/2109/files#diff-d1b1d4e3c1d5b653533620a0b77d0873a170c747a9bd5ae5db7d58f8606262d0R59
If I try out the above reproduction with that PR preview build, it seems to work: https://codesandbox.io/s/tannerlinsleyreact-query-basic-forked-vi4gt