SolidJSS
SolidJSโ€ข4y agoโ€ข
2 replies
binajmen

`xyz` is not a function

Hi,

I'm new to Solid/SolidStart and trying to play with prisma.

I have the following code:
import { For } from "solid-js";
import { useRouteData } from "solid-start";
import { createServerData$ } from "solid-start/server";
import { prisma } from "~/prisma";

export function data() {
  return createServerData$(() => prisma.user.findMany());
}

export default function Index() {
  const users = useRouteData<typeof data>();

  return (
    <div>
      Welcome to Hogwarts!
      <For each={users()}>{(user) => <p>{user.givenName}</p>}</For>
    </div>
  );
}

But I get the error:
TypeError: users is not a function
    at get each [as each] (http://localhost:3000/src/routes/admin/users/index.tsx:27:16)

There's no line 27, but clearly it does not like the fact I call users(). But it should be following the examples on https://start.solidjs.com/core-concepts/data-loading
SolidStart Beta Docuentation
Early release documentation and resources for SolidStart Beta
SolidStart Beta Documentation
Was this page helpful?