Skip to content

Commit d2d87ce

Browse files
committed
remove setKey
1 parent 16b2ef9 commit d2d87ce

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/docsearch-react/src/DocSearchButton.tsx

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

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

28-
const [key, setKey] = useState<
28+
const [key] = useState<
2929
typeof ACTION_KEY_APPLE | typeof ACTION_KEY_DEFAULT | null
30-
>(null);
31-
32-
useEffect(() => {
30+
>(() => {
3331
if (typeof navigator !== 'undefined') {
34-
setKey(isAppleDevice() ? ACTION_KEY_APPLE : ACTION_KEY_DEFAULT);
32+
return isAppleDevice() ? ACTION_KEY_APPLE : ACTION_KEY_DEFAULT;
3533
}
36-
}, []);
34+
return null;
35+
});
3736

3837
return (
3938
<button

0 commit comments

Comments
 (0)