Skip to content

Commit 3fc9ea4

Browse files
authored
fix(useResponsiveContentPadding - TypeScript): adjust types (#5039)
1 parent 932cefc commit 3fc9ea4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/base/src/hooks/useResponsiveContentPadding.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ const useStyles = createUseStyles<Range>(
1616
{ name: 'StdExtPadding' }
1717
);
1818

19-
export function useResponsiveContentPadding(element: HTMLElement, returnRangeString?: boolean): string;
20-
export function useResponsiveContentPadding(element: HTMLElement, returnRangeString: true): [string, Range];
19+
export function useResponsiveContentPadding(
20+
element: HTMLElement | undefined | null,
21+
returnRangeString?: boolean
22+
): string;
23+
24+
export function useResponsiveContentPadding(
25+
element: HTMLElement | undefined | null,
26+
returnRangeString: true
27+
): [string, Range];
2128

2229
/**
2330
* Hook for creating a style class, which sets `padding-left` and `padding-right` depending on the width of the element.
@@ -26,7 +33,7 @@ export function useResponsiveContentPadding(element: HTMLElement, returnRangeStr
2633
* @param {boolean} [returnRangeString=false] If set to `true`, returns a tuple with the class name and range.
2734
* @returns {(string|Array)} If `returnRangeString` is `true`, the hook returns a tuple with the class name on first and the range string on second position. Otherwise, only the class name string is returned.
2835
*/
29-
export function useResponsiveContentPadding(element: HTMLElement, returnRangeString = false) {
36+
export function useResponsiveContentPadding(element: HTMLElement | undefined | null, returnRangeString = false) {
3037
const [currentRange, setCurrentRange] = useState(() => getCurrentRange()?.name ?? 'Desktop');
3138
const classes = useStyles();
3239
const requestAnimationFrameRef = useRef<number | undefined>();

0 commit comments

Comments
 (0)