Skip to content

Commit bfd39a5

Browse files
fix(search): update Algolia search on language change (#4808)
Co-authored-by: Harsh Gupta <harsh16official@gmail.com> Co-authored-by: Prince Rajpoot <prince.rajpoot.20@gmail.com>
1 parent 2747eba commit bfd39a5

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

components/AlgoliaSearch.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ export default function AlgoliaSearch({ children }: { children: React.ReactNode
283283
*/
284284
export function SearchButton({ children, indexName = INDEX_NAME, ...props }: ISearchButtonProps) {
285285
const { onOpen, onInput } = useContext(SearchContext);
286-
const [Children, setChildren] = useState<string | React.ReactNode>('');
287286
const searchButtonRef = useRef<HTMLButtonElement>(null);
288287
const actionKey = getActionKey();
289288

@@ -309,13 +308,7 @@ export function SearchButton({ children, indexName = INDEX_NAME, ...props }: ISe
309308
};
310309
}, [onInput, searchButtonRef]);
311310

312-
useEffect(() => {
313-
if (typeof children === 'function') {
314-
setChildren(children({ actionKey }));
315-
} else {
316-
setChildren(children);
317-
}
318-
}, []);
311+
const childContent = typeof children === 'function' ? children({ actionKey }) : children;
319312

320313
return (
321314
<button
@@ -327,7 +320,7 @@ export function SearchButton({ children, indexName = INDEX_NAME, ...props }: ISe
327320
{...props}
328321
data-testid='Search-Button'
329322
>
330-
{Children}
323+
{childContent}
331324
</button>
332325
);
333326
}

0 commit comments

Comments
 (0)