Skip to content

Commit f19d1f2

Browse files
committed
remove setKey
1 parent 67a3667 commit f19d1f2

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/docsearch-react/src/DocSearch.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from './types';
1717
import { useDocSearchKeyboardEvents } from './useDocSearchKeyboardEvents';
1818

19-
const { useState, useEffect, useCallback, useRef } = React;
19+
const { useState, useCallback, useRef } = React;
2020

2121
const ACTION_KEY_APPLE = '⌘' as const;
2222
const ACTION_KEY_DEFAULT = 'Ctrl' as const;
@@ -52,15 +52,14 @@ export function DocSearch(props: DocSearchProps) {
5252
undefined
5353
);
5454

55-
const [key, setKey] = useState<
55+
const [key] = useState<
5656
typeof ACTION_KEY_APPLE | typeof ACTION_KEY_DEFAULT | null
57-
>(null);
58-
59-
useEffect(() => {
57+
>(() => {
6058
if (typeof navigator !== 'undefined') {
61-
setKey(isAppleDevice() ? ACTION_KEY_APPLE : ACTION_KEY_DEFAULT);
59+
return isAppleDevice() ? ACTION_KEY_APPLE : ACTION_KEY_DEFAULT;
6260
}
63-
}, []);
61+
return null;
62+
});
6463

6564
const onOpen = useCallback(() => {
6665
setIsOpen(true);
@@ -98,7 +97,6 @@ export function DocSearch(props: DocSearchProps) {
9897
</span>
9998
) : undefined}
10099
</DocSearchButton>
101-
102100
{isOpen &&
103101
createPortal(
104102
<DocSearchModal

0 commit comments

Comments
 (0)