Next.js error: cannot read properties of undefined (reading 'lenght')
I get this error: cannot read properties of undefined (reading 'lenght'): https://pastebin.com/JDxdK0u5
With this code:
Pastebin
Call StackuseSelector.skipCheckjavascript\node_modules.pnpm@legen...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.



2 Replies
React doesn't allow hooks to be called conditionally (https://legacy.reactjs.org/docs/hooks-rules.html)
You might wand something like
useQuery(convexApi.getCity.findCityById, typeof query.cityId === "string" ? { id: parseInt(query.cityId) } : "skip")
(See https://docs.convex.dev/client/react#skipping-queries)Rules of Hooks – React
A JavaScript library for building user interfaces
Convex React | Convex Developer Hub
Convex React is the client library enabling your React application to interact
Top, thank you, this skip feature is awesome