diff --git a/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts b/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts index 9657fb5607ef..c80ecf5b032b 100644 --- a/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts +++ b/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts @@ -5,16 +5,15 @@ * LICENSE file in the root directory of this source tree. */ -import type { - MutableRefObject} from 'react'; -import { - useState, - useCallback, - useEffect, - useRef -} from 'react'; - -export function useCodeWordWrap() { +import type {MutableRefObject} from 'react'; +import {useState, useCallback, useEffect, useRef} from 'react'; + +export function useCodeWordWrap(): { + readonly codeBlockRef: (node: HTMLPreElement | null) => void; + readonly isEnabled: boolean; + readonly isCodeScrollable: boolean; + readonly toggle: () => void; +} { const [isEnabled, setIsEnabled] = useState(false); const [isCodeScrollable, setIsCodeScrollable] = useState(false); const codeBlock = useRef() as MutableRefObject; @@ -49,8 +48,6 @@ export function useCodeWordWrap() { }, [isEnabled, updateCodeIsScrollable]); useEffect(() => { - updateCodeIsScrollable(); - window.addEventListener('resize', updateCodeIsScrollable, { passive: true, });