1
0
Fork 0

fix(docsearch): hoist transformItems default value

This fixes a bug where the `transformItems` function reference changes and the `autocomplete` instance is recreated every time.
This commit is contained in:
François Chalifour 2020-06-24 12:21:59 +02:00
parent 07932127ad
commit 1b9952fa9d

View file

@ -27,6 +27,10 @@ interface DocSearchModalProps extends DocSearchProps {
onClose?(): void;
}
function defaultTransformItems(x: DocSearchHit[]) {
return x;
}
export function DocSearchModal({
appId = 'BH4D9OD16A',
apiKey,
@ -34,7 +38,7 @@ export function DocSearchModal({
placeholder = 'Search docs',
searchParameters,
onClose = noop,
transformItems = (x) => x,
transformItems = defaultTransformItems,
hitComponent = Hit,
resultsFooterComponent = () => null,
navigator,