BillyBobB
tRPC2y ago
41 replies
BillyBob

Reusable Component to take router as props / dependency injection. How to type?

for example:
export const Content = async ({ api }) => {
  const items = await api.getAll.query({ watched: true })

  if (!items) {
    return <EmptyState />
  }

  return (
    <CardsContainer>
      {items.map((i) => {
        return <Card key={i.id} imgSrc={buildImgSrc(i.posterPath)} {...i} />
      })}
    </CardsContainer>
  )
}

Content is either movies or series.
I have movieRouter and seriesRouter with the same procedures.
How can i type api ?
Was this page helpful?