How do I query data with Tanstack Query if one of the query params can be undefined.
Hello,
I have an
id
variable that can be undefined because I get him from useParams
, and I use the id
value to query data with Tanstack Query, but Tanstack Query requires to have a value that cannot be undefined which is very logical. So I had to do Number(id) || 1
and enabled: !!id
this way:
Is this a common practice? And is there any other way to do this?
Thanks.1 Reply
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View