Skip to content

useErrorBoundary option works in useQueries? #2395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
luizeboli opened this issue Jun 22, 2021 Discussed in #2355 · 7 comments · Fixed by #4177
Closed

useErrorBoundary option works in useQueries? #2395

luizeboli opened this issue Jun 22, 2021 Discussed in #2355 · 7 comments · Fixed by #4177

Comments

@luizeboli
Copy link

Discussed in #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

@RichardLindhout
Copy link

I have the same problem but it does not work yet: #2109

@RichardLindhout
Copy link

Related: #1523

@TkDodo
Copy link
Collaborator

TkDodo commented Jun 25, 2021

does useErrorBoundary work in useQueries without suspense? Also, if you open an issue, please create a codesandbox example that reproduces the issue, thanks.

@luizeboli
Copy link
Author

luizeboli commented Jun 26, 2021

does useErrorBoundary work in useQueries without 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

@TkDodo
Copy link
Collaborator

TkDodo commented Jun 26, 2021

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

@RichardLindhout
Copy link

Yes useQueries works perfectly without suspense! I only missed an option for refetchInterval in useQueries

@TkDodo
Copy link
Collaborator

TkDodo commented Jun 26, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants