Replies: 2 comments 2 replies
-
My first question is, why are you copying values from the |
Beta Was this translation helpful? Give feedback.
2 replies
-
Maybe you can wrap the const arr = []
const useGetApplicationsQueryDefault = () => {
const resp = useGetApplicationsQuery()
return resp.data === undefined ? {...resp, data: arr} : resp
} Not sure if that's the best way to keep the reference stable here, but i think it works. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What's a good way to handle default return values in RTK Query. For example the following is something I do often :
This works fine in most cases. However, if i need to put it into dependencies of useEffect for further processing then i get a recursive update cycle in case the API is down and not returning data.
setDisplayedData in useEffect triggers a rerender which itself initiates applications to a new array with a new reference which triggers useEffect...
Of course i could do the following
However, i need
applications
throughout my component in many different places and handling the default value as array makes life much easier than checking ifapplications
is really an array orundefined
.Does anyone have suggestions for this usecase or am I totally missing something here?
Beta Was this translation helpful? Give feedback.
All reactions