You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What you were expecting:
In the same resources, I have a function of GetList when the condition is true (that is, when the condition is not true, GetList is in a disabled state, which is not true by default); at this time, I click delete. I expect the deletion to be successful and no error is reported.
What happened instead:
Under the same resources, when I execute useDelete successfully, useGetList whose status is disabled reports an error.
Steps to reproduce:
Click the delete button and delete successfully.
Analysis:
In my useGetList, I set the value of enabled as a condition. When the condition is triggered, the list will be obtained. At this time, the value of my useGetList is undefined; when I execute useDelete successfully, it tries to update the cache. Execute the onSuccess passed to the third parameter of useQuery in the source code of useGetList, and onSuccess tries to get the data from the value, resulting in an error.
Solution
1 In all useGetLists that are disabled by default, add ‘ initialData: { data: [] } ’
The text was updated successfully, but these errors were encountered:
zhiguow
changed the title
When useGetList is in the disabled state, when the cache is updated somewhere, the error value is undefined.
[BUG] When useGetList is in the disabled state, when the cache is updated somewhere, the error value is undefined.
May 24, 2023
zhiguow
changed the title
[BUG] When useGetList is in the disabled state, when the cache is updated somewhere, the error value is undefined.
When useGetList is in the disabled state, when the cache is updated somewhere, the error value is undefined.
May 24, 2023
I would have appreciated a reproduction sandbox, but your report was detailed enough so that I could understand the problem anyway.
Both your workarounds are valid, although, I'd recommend the first one (providing initialData) because the second one is basically bypassing react-query altogether and hence removing its benefits.
In any case, I believe that useGetList.ts should be fixed because this proves we should not assume that value has a data property at anytime.
Hence I'll label this as a bug.
This issue is also present on useGetManyReference. I rewrote it to use useGetList to bypass it, but I think useGetManyReference should be fixed as well.
What you were expecting:
In the same resources, I have a function of GetList when the condition is true (that is, when the condition is not true, GetList is in a disabled state, which is not true by default); at this time, I click delete. I expect the deletion to be successful and no error is reported.
What happened instead:
Under the same resources, when I execute useDelete successfully, useGetList whose status is disabled reports an error.
Steps to reproduce:
Click the delete button and delete successfully.
Related code:
Analysis:
In my useGetList, I set the value of enabled as a condition. When the condition is triggered, the list will be obtained. At this time, the value of my useGetList is undefined; when I execute useDelete successfully, it tries to update the cache. Execute the onSuccess passed to the third parameter of useQuery in the source code of useGetList, and onSuccess tries to get the data from the value, resulting in an error.
Solution
1 In all useGetLists that are disabled by default, add ‘ initialData: { data: [] } ’
2 Do not use useDelete, use dataProvider.delete, and use the refresh method in finally
Environment
The text was updated successfully, but these errors were encountered: