diff --git a/components/lib/hooks/hooks.d.ts b/components/lib/hooks/hooks.d.ts index b711668a84..4898d4b2fc 100644 --- a/components/lib/hooks/hooks.d.ts +++ b/components/lib/hooks/hooks.d.ts @@ -67,6 +67,7 @@ interface EventOptions { options?: any; /** * Whether to listen to the event or not. + * @defaultValue true */ when?: boolean; } @@ -89,6 +90,7 @@ interface OverlayEventOptions { listener?(event: Event, type?: string): void; /** * Whether to listen to the event or not. + * @defaultValue true */ when?: boolean; } @@ -102,6 +104,11 @@ interface ResizeEventOptions { * @param {Event} event - The browser event object. */ listener?(event: Event): void; + /** + * Whether to listen to the event or not. + * @defaultValue true + */ + when?: boolean; } /** diff --git a/components/lib/hooks/useResizeListener.js b/components/lib/hooks/useResizeListener.js index 4e4fa9e9fd..6bfca70390 100644 --- a/components/lib/hooks/useResizeListener.js +++ b/components/lib/hooks/useResizeListener.js @@ -1,8 +1,9 @@ import { useEventListener } from './useEventListener'; -export const useResizeListener = ({ listener }) => +export const useResizeListener = ({ listener, when = true }) => useEventListener({ target: 'window', type: 'resize', - listener + listener, + when });