#Next.js error: cannot read properties of undefined (reading 'lenght')

1 messages · Page 1 of 1 (latest)

jagged ice
#

I get this error: cannot read properties of undefined (reading 'lenght'): https://pastebin.com/JDxdK0u5

With this code:

const InternalHome = observer(() => {
 // ...
  const { locale, query, replace } = useRouter();

  const cityById =
    typeof query.cityId === "string"
      ? useQuery(convexApi.getCity.findCityById, {
          id: parseInt(query.cityId),
        })
      : undefined;
empty phoenix
#

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)

Convex React is the client library enabling your React application to interact