Skip to content

RFC: pass variables on refetch #1119

Closed Answered by tannerlinsley
Belco90 asked this question in General
Discussion options

You must be logged in to vote

Does this not solve your issue?

const fetchUsersQueryFn = async (key, queryArgs) => {
  const { results } = await readUsers(queryArgs)
  return results
}

const SearchUsers = () => {
  const [inputValue, setInputValue] = React.useState('')

  const { data } = useQuery(['users', { q: inputValue }], fetchUsersQueryFn, {
    enabled: !!inputValue,
  })

  return (
    <Async
      loadOptions={setInputValue}
      defaultOptions={data}
      // ...
    />
  )
}

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Belco90
Comment options

@tannerlinsley
Comment options

@Belco90
Comment options

@TkDodo
Comment options

@Belco90
Comment options

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