Conditional fetching #14
Unanswered
cdedreuille
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Would adding a const filter = useFilter(
(query) => query.eq('id', router.query.id).single(),
[router.query],
)
const [{ data: vendor, error }] = useSelect('vendors', {
filter,
pause: router.query.id === null
}); If so, this should be a quick feature to add. You are also welcome to open a PR with this change too. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How do you handle conditional fetching?
In my case, I'm using Nextjs and with Next router queries are asynchronous so you first get
null
when you use something likerouter.query.id
I'm using this for now but it first makes a query that results in a 404. It works but I guess it's not the most efficient as it creates 2 queries.
Beta Was this translation helpful? Give feedback.
All reactions