Skip to content

How to execute query based on click event?? #1656

Answered by JoviDeCroock
shamxeed asked this question in Q&A
Discussion options

You must be logged in to vote
const MyComponent = () => {
  const [result, execute] = useQuery({ query: yourQuery, pause: true });
  
   const onlick = () => {
     // You can pass in context here, example requestPlicy
     execute({ requestPolicy: 'network-only' })
   }
}

pause is used to not automatically fire as mentioned in the docs

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@shamxeed
Comment options

@shamxeed
Comment options

@JoviDeCroock
Comment options

@shamxeed
Comment options

Answer selected by JoviDeCroock
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