Closed jonlaing closed 1 week ago
Okay, I just figured out what I did wrong. The query
variable is instantiated at load time of the file, rather than at runtime of the useEffect
, so it's essentially chaining the eq('id', postId)
portion every time the useEffect
runs, rather than building a new query each time. That's my bad. Closing the issue, but leaving this for posterity in case anyone else makes the silly mistake I did.
Bug report
Describe the bug
I have an expo app in which I have a lists of posts that you can click into. The list of posts works fine. However, when clicking into a post and I try to fetch an individual post, the first time will be successful, but each subsequent fetch will be unsuccessful, even when going back to the same post.
To Reproduce
On initial fetch I receive the post as expected:
But if I go back, and try again, I'll receive an error:
Expected behavior
I would expect the fetch to return a post given a valid id. I've checked and it is indeed using valid id's, as evidenced by it working the first time.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
Additional context
I'm using
expo-router
and the page in question is named/posts/[id].tsx
so I don't know if that's relevant. I have the app logging the postId, and it's correct every time, so I can't imagine there's an issue there, but I could be wrong.Also, I used Prisma for all of my database creation and migration, so also not sure if that's relevant.
Thanks!