From 55b9e7a7e0cd751dc818164d125743c3f22c2e9b Mon Sep 17 00:00:00 2001 From: chenxsan Date: Wed, 21 Jul 2021 20:47:39 +0800 Subject: [PATCH] use useMemo --- packages/docsearch-react/src/DocSearchButton.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/docsearch-react/src/DocSearchButton.tsx b/packages/docsearch-react/src/DocSearchButton.tsx index 7c089503a..5d5085103 100644 --- a/packages/docsearch-react/src/DocSearchButton.tsx +++ b/packages/docsearch-react/src/DocSearchButton.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useMemo } from 'react'; import { ControlKeyIcon } from './icons/ControlKeyIcon'; import { SearchIcon } from './icons/SearchIcon'; @@ -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 (