SolidJSS
SolidJSโ€ข3y agoโ€ข
7 replies
gh680

Can't get createServerData$ to work as expected

I have other projects that use routeData / createServerData$ / useRouteData that work fine. This one is giving me fits.
In the below, trying to read the records() accessor gives me "records is not a function"
import { For } from 'solid-js'
import { createServerData$ } from 'solid-start/server'
import { useRouteData } from 'solid-start'
import prisma from '~/db/prisma'

export function routeData() {
    return createServerData$(async () => {
        const data = await prisma.company.findMany({})
        return data
    })
}

export default function TableView() {
    const records = useRouteData<typeof routeData>()

    return (
        <div>
            <For each={records()}>{rec => <p>{rec.name}</p>}</For>
        </div>
    )
}

My prisma schema/client are cool, typings there are good. I've reduced the code to a minimal example and it still doesn't work. I've tried everything I know, and still no joy. Ideas anyone? Thanks
Was this page helpful?