T

tRPC

โ“-help

Join Server

Cannot read properties of undefined (reading 'createTRPCReact')

IIndustrial3/12/2023
I'm trying to use it in an Astro project.

https://github.com/Industrial/test-astro-solid/blob/main/src/lib/trpc.ts

I think I implemented it as per the example https://trpc.io/docs/react#2-create-trpc-hooks
Bbackbone3/12/2023
I don't know why.but please try pnpm install again or restart VSCode.
IIndustrial3/12/2023
@backbone I did rm -rf node_modules && pnpm install and same thing
IIndustrial3/12/2023
@backbone could you run git clone git@github.com:Industrial/test-astro-solid.git && cd test-astro-solid && pnpm i && pnpm dev to reproduce ?
Bbackbone3/13/2023
Sorry, I would try this repo
IIndustrial3/13/2023
Thank you ๐Ÿ™‚
IIndustrial3/13/2023
I got it! I'm using SolidJS and not React so I don't need react-query.
IIndustrial3/13/2023
import { createResource } from 'solid-js'
import type { JSX } from 'solid-js/jsx-runtime'

import { trpc } from '@/lib/trpc'

export const Test = (): JSX.Element => {
  const userId = '123'
  const [user, { mutate, refetch }] = createResource(userId, async (id: string) => {
    return await trpc.getUserById.query(id)
  })
  return <div>USER? {JSON.stringify(user())}</div>
}
IIndustrial3/13/2023
That's all you need ๐Ÿ™‚