Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(hooks-web): don't pass widget props to ui components (#3501)
Browse files Browse the repository at this point in the history
* fix(hooks-web): don't pass widget props to ui components

Similar to #3499, but i did a search for other places props was used literally in -web

We'd get a typescript error for these if microsoft/TypeScript#39998 was fixed, but that doesn't seem to be on their table yet

* Update packages/react-instantsearch-hooks-web/src/widgets/HitsPerPage.tsx

Co-authored-by: François Chalifour <francoischalifour@users.noreply.github.com>

Co-authored-by: François Chalifour <francoischalifour@users.noreply.github.com>
  • Loading branch information
Haroenv and francoischalifour authored Jun 6, 2022
1 parent 2cdf906 commit 5bd53c1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
13 changes: 9 additions & 4 deletions packages/react-instantsearch-hooks-web/src/widgets/Hits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ export type HitsProps<THit extends BaseHit> = Omit<
> &
UseHitsProps<THit>;

export function Hits<THit extends BaseHit = BaseHit>(props: HitsProps<THit>) {
const { hits, sendEvent } = useHits<THit>(props, {
$$widgetType: 'ais.hits',
});
export function Hits<THit extends BaseHit = BaseHit>({
escapeHTML,
transformItems,
...props
}: HitsProps<THit>) {
const { hits, sendEvent } = useHits<THit>(
{ escapeHTML, transformItems },
{ $$widgetType: 'ais.hits' }
);

const uiProps: UiProps<THit> = {
hits,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ export type HitsPerPageProps = Omit<
> &
UseHitsPerPageProps;

export function HitsPerPage(props: HitsPerPageProps) {
const { items, refine } = useHitsPerPage(props, {
$$widgetType: 'ais.hitsPerPage',
});
export function HitsPerPage({
items: userItems,
transformItems,
...props
}: HitsPerPageProps) {
const { items, refine } = useHitsPerPage(
{ items: userItems, transformItems },
{ $$widgetType: 'ais.hitsPerPage' }
);
const { value: currentValue } =
items.find(({ isRefined }) => isRefined)! || {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@ export type InfiniteHitsProps<THit extends BaseHit = BaseHit> = Omit<

export function InfiniteHits<THit extends BaseHit = BaseHit>({
showPrevious: shouldShowPrevious = true,
cache,
escapeHTML,
showPrevious: userShowPrevious,
transformItems,
...props
}: InfiniteHitsProps<THit>) {
const { hits, sendEvent, showPrevious, showMore, isFirstPage, isLastPage } =
useInfiniteHits<THit>(props, { $$widgetType: 'ais.infiniteHits' });
useInfiniteHits<THit>(
{ cache, escapeHTML, showPrevious: userShowPrevious, transformItems },
{ $$widgetType: 'ais.infiniteHits' }
);

const uiProps: UiProps<THit> = {
hits,
Expand Down

0 comments on commit 5bd53c1

Please sign in to comment.