Skip to content

[proposal, workarounds] Dependent and optional queries share an overloaded API #4589

Answered by TkDodo
asktree asked this question in Ideas
Discussion options

You must be logged in to vote

it seems like you want a return value for something that you already know, as you pass it into an option of react-query. consider:

const isEnabled = someCondition()
const isReady = someOtherCondition()

const { status, fetchStatus } = useQuery({ queryKey, queryFn, enabled: isEnabled && isReady })

now you don't have to inspect status or fetchStatus to know what state the query is in. For react-query, there is only one state - the query(observer) is disabled. Internally, there is no need to differentiate: it doesn't matter why the query isn't running.

if it matters to you, you can still check for isEnabled or isReady - the variables / conditions you have implicitly available because you pa…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@asktree
Comment options

@asktree
Comment options

Answer selected by asktree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants