how to Re-hydrate query data ?
I want to call the query again every time my currentPage changes, but the way it's coded in the print example, the pages re-renders in a weird way and my pagination component doesn't work as expected.
6 Replies
Hi @Rômullo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Hmm, I don't know enough to give you a confident answer yet. However, in Wasp, you can use the
useQuery
hook to make your component reactive. This means that React will re-render the component every time the Query changes. Wasp automatically refreshes Queries whenever the data is modified. This might be helpful in your case where you want to re-fetch the data every time the currentPage changes.
Here is an example of how to use the useQuery
hook in Wasp:
In this example, the useQuery
hook is used to fetch a task. Every time the id
prop changes, the useQuery
hook will re-fetch the task.
For more detailed information, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/tutorial/queries#invoking-the-query-on-the-frontend).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Rômullo, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?full page code
when i click on another page, setCurrentPage is called, query is called, new data is rendered
Wohooo @Rômullo, you just became a Waspeteer level 1!
but the page blinks, there is any way to prevent this ?
"blinks" - as in the data is being loaded? you need to handle your loading state probably, while the data is being loaded?