TypeScript hitComponent type?

Assuming we want to render a custom hitComponent using the <Hits /> component from react-instantsearch-hooks-web, when using:

<Hits hitComponent={Hit} /> what is the proper way to type the <Hit> component?

eg: function Hit({ hit }: { hit: ??? }) { }

@sf1

It looks like you should use the AlgoliaHit class and inherit from your custom type, for example:

export interface ProductRecord {
  name: string
  price: number
}

AlgoliaHit<ProductRecord>

I’ve found an example here:

1 Like