44 Replies
hey! yeah, the issue is that
parcel._id
is a special Id
class, not a plain string. when you put it into the URL with string substitution, it calls Id.toString()
on it.
so, what you can do is...
(assuming the name of the table is "parcels")
lmk if that workswhat do I import for Id?
for if im not using TS
ok figured it out

im getting this error now

get parcel looks like this
ah, okay! so you need to change your URL to
same issue
huh, can you
console.log(idString)
and see what it's printing out?
before the useQuery

What are you importing to create your Id? There should be a class in
convex/_generated/dataModel.js
I believe
yep
also, I think changing it to
should work
(i thought
useParams
returns a string but it's actually an object ^^)yep, it works
thank you!
lifesaver
Yeah sorry -- I assumed you were printing the
Id
and not the useParams
. Glad everything's working now 🎉@sujayakar this is printing out undefined

for both items

but these fields exist in my database
useQuery will return undefined on the initial render. After the query finishes executing, it will trigger a rerender that should have the result of the query
it appears to always show undefined
can you
console.log(parcel)
?
here is full code

ah and actually doing something like
would help too
I wonder if we didn't recreate the
Id
correctly, which then means that db.get
is always returning null

cool. if you go to the dashboard for your deployment, do you see the
getParcels:getParcel
call in the logs view?yeah, latest from 5:34AM
Even if db.get were returning null, queryResult would only be undefined before the query has finished executing. Makes me think something is getting in the way of the rerender
Yeah I would perhaps try commenting out everything except the
useQuery
and console.log
s in my component and see if a re-render gives us the right resulteverything deleted
still shows up null
oh
i think i found the error
its parcel not parcels
mb
ahh nice! works now?
ok works when theres no react components rendering
but not when i add in the return
Is it possible that on the first render, when useQuery returns undefined, the undefined value makes the component throw an exception, so the rerender never happens?
possibly, but how do I fix it?
can you paste the rest of the component code? after the
useQuery
In my convex apps i sometimes do something like
if (queryResult === undefined) { return <div>Loading...</div> }
doesnt work for me

fixed
thanks
(was going to tell you to remove the
|| {}
but looks like you figured it out!)