You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a new Blitz app after generating basic CRUD models/pages, when visiting /projects/:projectIdprojectId value is missing on first render. Subsequent renders contain the correct parameters.
Update: This comes from Next.js. The reason params are empty on initial render is because react requires first render on the client to be the same as the static html. And since these pages are generated statically at build time without any params, params must be empty on first render on the client. See vercel/next.js#8259 for more context.
Partial Solution
blitz-js/blitz#1422 adds a default enabled flag to all useQuery hooks that disables queries on the first render when the params are empty. So this should fix the common use case and issue with useQuery.
What is the problem?
In a new Blitz app after generating basic CRUD models/pages, when visiting
/projects/:projectId
projectId
value is missing on first render. Subsequent renders contain the correct parameters.const projectId = useParam("projectId", "number")
=NaN
.This leads to a Prisma error, because NaN is passed as the argument for the ID.
Steps to Reproduce
blitz new app-name
blitz generate all project name:string
blitz db migrate
http://localhost:3000/project/1
Versions
Other
The text was updated successfully, but these errors were encountered: