Skip to content
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

useQueryWithStore and useGetMany returns error: null when success after firs fail #3983

Merged
merged 1 commit into from
Nov 14, 2019

Conversation

Slavvkko
Copy link
Contributor

I use useGetManyReference to get referenced data.

  const { data, ids, error, loaded } = useGetManyReference(
    "decks",
    "branchId",
    branch.id,
    { page: 1, perPage: 200 },
    { field: "id", order: "ASC" },
    {},
    "branches"
  );

When get fails at first call I got this log (from last render):

data: undefined, error: Error: ra.notification.data_provider_error, loading: false, loaded: false

In this case we show error text because data is undefined and error is present.

When get fails after some success calls before I got this log (from last render):

data: [object Object], error: Error: ra.notification.data_provider_error, loading: false, loaded: true

In this case we show error text, because error is present. Even if data is present and loaded is true, because this data may be outdated.

Then refresh again, for now I got success response:

data: [object Object], error: Error: ra.notification.data_provider_error, loading: false, loaded: true

But in this case error is presented again and I need to show error instead of data.

With fix after success response:

data: [object Object], error: null, loading: false, loaded: true

And in this case success response will return error: null so I can show data.

Copy link
Contributor

@djhi djhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@fzaninotto fzaninotto merged commit 26bde6d into marmelab:next Nov 14, 2019
@fzaninotto
Copy link
Member

Awesome, thanks!

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 this pull request may close these issues.

None yet

3 participants