Skip to content

Commit 55b9e7a

Browse files
committed
use useMemo
1 parent d2d87ce commit 55b9e7a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/docsearch-react/src/DocSearchButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import React, { useMemo } from 'react';
22

33
import { ControlKeyIcon } from './icons/ControlKeyIcon';
44
import { SearchIcon } from './icons/SearchIcon';
@@ -25,14 +25,14 @@ export const DocSearchButton = React.forwardRef<
2525
>(({ translations = {}, ...props }, ref) => {
2626
const { buttonText = 'Search', buttonAriaLabel = 'Search' } = translations;
2727

28-
const [key] = useState<
28+
const key = useMemo<
2929
typeof ACTION_KEY_APPLE | typeof ACTION_KEY_DEFAULT | null
3030
>(() => {
3131
if (typeof navigator !== 'undefined') {
3232
return isAppleDevice() ? ACTION_KEY_APPLE : ACTION_KEY_DEFAULT;
3333
}
3434
return null;
35-
});
35+
}, []);
3636

3737
return (
3838
<button

0 commit comments

Comments
 (0)