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

Commit

Permalink
Merge branch 'master' into test/rerenders
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour authored Jun 6, 2022
2 parents 2f38c97 + 5bd53c1 commit 8584d79
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 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
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ type UiProps = Pick<
export type SearchBoxProps = Omit<SearchBoxUiComponentProps, keyof UiProps> &
UseSearchBoxProps;

export function SearchBox(props: SearchBoxProps) {
const { query, refine, isSearchStalled } = useSearchBox(props, {
$$widgetType: 'ais.searchBox',
});
export function SearchBox({ queryHook, ...props }: SearchBoxProps) {
const { query, refine, isSearchStalled } = useSearchBox(
{ queryHook },
{ $$widgetType: 'ais.searchBox' }
);
const [value, setValue] = useState(query);
const inputRef = useRef<HTMLInputElement>(null);

Expand Down

0 comments on commit 8584d79

Please sign in to comment.