Skip to content
Discussion options

You must be logged in to vote

given that you manage the data from the external library within react (e.g. useState, some global client state manager, or even react-query if that data comes from an api call), the best way is to set enabled to a dynamic value, so that the query then enables automatically once the data comes in. So you're really looking at a standard dependent query:

const dataFromExternalLib = useDataFromExternalLib()

const { data } = useQuery(
  ['something', dataFromExternalLib],
  () => fetchSomething(dataFromExternalLib),
  {
    enabled: !!dataFromExternalLib
  }
)

Replies: 1 comment 2 replies

Comment options

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

@TkDodo
Comment options

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