Skip to content

Commit

Permalink
use useMemo
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxsan committed Jul 21, 2021
1 parent d2d87ce commit 55b9e7a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/docsearch-react/src/DocSearchButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useMemo } from 'react';

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

const [key] = useState<
const key = useMemo<
typeof ACTION_KEY_APPLE | typeof ACTION_KEY_DEFAULT | null
>(() => {
if (typeof navigator !== 'undefined') {
return isAppleDevice() ? ACTION_KEY_APPLE : ACTION_KEY_DEFAULT;
}
return null;
});
}, []);

return (
<button
Expand Down

0 comments on commit 55b9e7a

Please sign in to comment.