Skip to content

Commit

Permalink
fix(docsearch): hoist transformItems default value
Browse files Browse the repository at this point in the history
This fixes a bug where the `transformItems` function reference changes and the `autocomplete` instance is recreated every time.
  • Loading branch information
francoischalifour committed Jun 24, 2020
1 parent 0793212 commit 1b9952f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/DocSearchModal.tsx
Expand Up @@ -27,14 +27,18 @@ interface DocSearchModalProps extends DocSearchProps {
onClose?(): void;
}

function defaultTransformItems(x: DocSearchHit[]) {
return x;
}

export function DocSearchModal({
appId = 'BH4D9OD16A',
apiKey,
indexName,
placeholder = 'Search docs',
searchParameters,
onClose = noop,
transformItems = (x) => x,
transformItems = defaultTransformItems,
hitComponent = Hit,
resultsFooterComponent = () => null,
navigator,
Expand Down

0 comments on commit 1b9952f

Please sign in to comment.