From 2cdf90602b7c2c5895124ef64c389ce574154386 Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Mon, 6 Jun 2022 13:25:31 +0200 Subject: [PATCH 1/2] fix(SearchBox-hooks): correctly pass widget props (#3499) The prop "queryHook" is not a dom property, so shouldn't be passed to the ui component fixes #3498 --- .../src/widgets/SearchBox.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/react-instantsearch-hooks-web/src/widgets/SearchBox.tsx b/packages/react-instantsearch-hooks-web/src/widgets/SearchBox.tsx index 8bb3a93893..435889613c 100644 --- a/packages/react-instantsearch-hooks-web/src/widgets/SearchBox.tsx +++ b/packages/react-instantsearch-hooks-web/src/widgets/SearchBox.tsx @@ -19,10 +19,11 @@ type UiProps = Pick< export type SearchBoxProps = Omit & 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(null); From 5bd53c128ddeeea87f75ae89eb8f2324d476c70e Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Mon, 6 Jun 2022 17:28:59 +0200 Subject: [PATCH 2/2] fix(hooks-web): don't pass widget props to ui components (#3501) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 https://github.com/microsoft/TypeScript/issues/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 Co-authored-by: François Chalifour --- .../src/widgets/Hits.tsx | 13 +++++++++---- .../src/widgets/HitsPerPage.tsx | 13 +++++++++---- .../src/widgets/InfiniteHits.tsx | 9 ++++++++- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/packages/react-instantsearch-hooks-web/src/widgets/Hits.tsx b/packages/react-instantsearch-hooks-web/src/widgets/Hits.tsx index 1ac1860f3e..f46d670c9f 100644 --- a/packages/react-instantsearch-hooks-web/src/widgets/Hits.tsx +++ b/packages/react-instantsearch-hooks-web/src/widgets/Hits.tsx @@ -18,10 +18,15 @@ export type HitsProps = Omit< > & UseHitsProps; -export function Hits(props: HitsProps) { - const { hits, sendEvent } = useHits(props, { - $$widgetType: 'ais.hits', - }); +export function Hits({ + escapeHTML, + transformItems, + ...props +}: HitsProps) { + const { hits, sendEvent } = useHits( + { escapeHTML, transformItems }, + { $$widgetType: 'ais.hits' } + ); const uiProps: UiProps = { hits, diff --git a/packages/react-instantsearch-hooks-web/src/widgets/HitsPerPage.tsx b/packages/react-instantsearch-hooks-web/src/widgets/HitsPerPage.tsx index 39bf998eeb..87ea1483cd 100644 --- a/packages/react-instantsearch-hooks-web/src/widgets/HitsPerPage.tsx +++ b/packages/react-instantsearch-hooks-web/src/widgets/HitsPerPage.tsx @@ -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)! || {}; diff --git a/packages/react-instantsearch-hooks-web/src/widgets/InfiniteHits.tsx b/packages/react-instantsearch-hooks-web/src/widgets/InfiniteHits.tsx index 066d2572d8..7f52377022 100644 --- a/packages/react-instantsearch-hooks-web/src/widgets/InfiniteHits.tsx +++ b/packages/react-instantsearch-hooks-web/src/widgets/InfiniteHits.tsx @@ -33,10 +33,17 @@ export type InfiniteHitsProps = Omit< export function InfiniteHits({ showPrevious: shouldShowPrevious = true, + cache, + escapeHTML, + showPrevious: userShowPrevious, + transformItems, ...props }: InfiniteHitsProps) { const { hits, sendEvent, showPrevious, showMore, isFirstPage, isLastPage } = - useInfiniteHits(props, { $$widgetType: 'ais.infiniteHits' }); + useInfiniteHits( + { cache, escapeHTML, showPrevious: userShowPrevious, transformItems }, + { $$widgetType: 'ais.infiniteHits' } + ); const uiProps: UiProps = { hits,