-
Hi, I'm currently trying to correctly type my Assuming I have this setup <InstantSearch indexName="books" searchClient={searchClient}>
<SearchBox />
<Hits hitComponent={Hit} />
</InstantSearch> Further assuming I know that the hit documents will include an attribute called const Hit: React.FC<{ hit: HitsProps<{ name: string }> }> = ({ hit }) => {
return <div>{hit.name}</div>; // TS2339: Property name does not exist on type HitsProps<{ name: string; }>
}; How do I type the hit correctly so that I can access my document's attributes typesafe in my custom Thanks! :) |
Beta Was this translation helpful? Give feedback.
Answered by
dhayab
Dec 26, 2023
Replies: 1 comment 1 reply
-
Here's an example of how it could be typed: import type { Hit } from 'instantsearch.js';
type HitProps = {
hit: Hit<{
name: string;
}>;
};
const Hit: React.FC<HitProps> = ({ hit }) => {
return <div>{hit.name}</div>;
}; |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
theovier
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's an example of how it could be typed: