-
-
Couldn't load subscription status.
- Fork 1.2k
Description
Edited based on discussion below
The docs could be more clear about the expected/required return value from selectFromResult (and maybe reasons for those expectations)
Original issue:
As the title states, if the selectFromResult function returns a value directly, it results in the following error:
rtk-query-react.esm.js:318 Uncaught TypeError: Cannot read properties of undefined (reading 'data')
The issue appears to stem from useQuery relying on useQueryState which returns undefined after a few renders, causing the above error on this line:
redux-toolkit/packages/toolkit/src/query/react/buildHooks.ts
Lines 963 to 972 in e454251
| const queryStateResults = useQueryState(arg, { | |
| selectFromResult: | |
| arg === skipToken || options?.skip | |
| ? undefined | |
| : noPendingQueryStateSelector, | |
| ...options, | |
| }) | |
| const { data, status, isLoading, isSuccess, isError, error } = | |
| queryStateResults |
This behavior may be intentional - if so, the docs should be updated to reflect that.