lazy query
hey all, I was working on a project yesterday and I needed a "lazy" query to happen when I clicked a search button. I realized I could use a mutation for this, and still just query data within the handler. I realize this is probably well-known, but I tried to find it mentioned in the docs as a "tip" or something. I couldn't find it. Is this in the docs somewhere? Are there any other useful tips like this?
2 Replies
1. you can create a React component that is only rendered when you click on the search button, and put the
useQuery
in there
2. you can pass "skip" as the query arguments until the button is pressed, and the query won't run until the arguments change to something else
3. you can do a oneoff non-reactive query with convex = useConvex()
and await convex.query(args)
oh, that's great - especially 3. I've used something similar with trpc.
thanks @Lee