backo
backo15mo ago

How can I reset the cursor when using useInfiniteQuery?

I have various filters that I can set for the query, but when setting those filters I need to reset the cursor to undefined before setting the filter. Right now when I set the filter, the last cursor is always being sent. How can I reset it? What I've tried is calling invalidate and reset on the query, but the cursor is not being set to undefined as can be seen in the screenshot. Any ideas? Thanks! 🙂
2 Replies
backo
backo15mo ago
it seems related to the initialCursor, it is being set on props returned from getServerSideProps. If I assign it to a state value and then reset said state value, the change is actually reflected in the cursor. Is this expected behavior? 🙂
backo
backo15mo ago
Just wanted to say that it works fine with useState, so i'll leave it that way. 🙂