S
SolidJS•2y ago
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>
);
}
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)
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
SolidStart Beta Documentation
Early release documentation and resources for SolidStart Beta
1 Reply
binajmen
binajmen•2y ago
Mmmh okay we MUST call it routeData to make the magic works 🙂 I didn't know it was a naming convention !