Skip to content
New issue

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

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

Already on GitHub? # to your account

Throw an error when useGetOne is called for an undefined resource #4430

Merged
merged 2 commits into from
May 7, 2020

Conversation

fzaninotto
Copy link
Member

Problem

useQuery works even without a <Resource> because it doesn't rely on the Redux store. However, developers may want to use the more specialized hooks, like useGetOne(). These only work if there is a <Resource>, but for now if there is no resource the hook returns null - which is not a good developer experience.

Solution

This change throws an error in case of missing Resource for useGetOne. It's a start. It's a bit harder to do for other data Provider hooks, so let's start with this baby step/

@fzaninotto fzaninotto added this to the 3.3.0 milestone Feb 19, 2020
@fzaninotto fzaninotto removed this from the 3.3.0 milestone Mar 4, 2020
@fzaninotto fzaninotto force-pushed the usegetone-error-in-no-ressource branch from 3844196 to 4b01ee6 Compare May 7, 2020 15:48
@fzaninotto fzaninotto added the RFR Ready For Review label May 7, 2020
@fzaninotto fzaninotto merged commit 97b99b8 into next May 7, 2020
@fzaninotto fzaninotto deleted the usegetone-error-in-no-ressource branch May 7, 2020 16:01
@fzaninotto fzaninotto added this to the 3.6.0 milestone May 7, 2020
@fzaninotto
Copy link
Member Author

This caused a regression in 3.6.0, which should be fixed by #4990 (released in 3.6.3).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants