Skip to content

Commit 4bdd80b

Browse files
author
Hector Arce De Las Heras
committed
Pretiffier useImperativeHandle
1 parent c92f2ed commit 4bdd80b

File tree

6 files changed

+42
-18
lines changed

6 files changed

+42
-18
lines changed

src/components/listOptions/listOptionsStandAlone.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ export const ListOptionsStandAlone = React.forwardRef(
4040
const [focus, setFocus, listEl] = useRoveFocus(props.roveFocus ?? roveFocusProps);
4141
const _id = useId();
4242

43-
React.useImperativeHandle(ref, () => {
44-
return listEl.current as HTMLDivElement;
45-
}, []);
43+
React.useImperativeHandle(
44+
ref,
45+
() => {
46+
return listEl.current as HTMLDivElement;
47+
},
48+
[]
49+
);
4650

4751
const id = props.id ?? _id;
4852
const isSelection = type === ListOptionsType.SELECTION;

src/components/option/option.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ export const OptionComponent = React.forwardRef(
2020
const [hover, setHover] = React.useState(false);
2121
const [focused, setFocused] = React.useState(false);
2222

23-
React.useImperativeHandle(ref, () => {
24-
return innerRef.current as HTMLElement;
25-
}, []);
23+
React.useImperativeHandle(
24+
ref,
25+
() => {
26+
return innerRef.current as HTMLElement;
27+
},
28+
[]
29+
);
2630

2731
React.useEffect(() => {
2832
if (focus) {

src/components/pillSelector/pillSelectorControlled.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ const PillSelectorControlledComponent = React.forwardRef(
3838
}
3939
};
4040

41-
React.useImperativeHandle(ref, () => {
42-
return measuredRef.current as HTMLDivElement;
43-
}, []);
41+
React.useImperativeHandle(
42+
ref,
43+
() => {
44+
return measuredRef.current as HTMLDivElement;
45+
},
46+
[]
47+
);
4448

4549
React.useEffect(() => {
4650
let resizeObserver: ResizeObserver;

src/components/pillSelector/pillSelectorStandAlone.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ const PillSelectorStandAloneComponent = (
3030

3131
const isPillSelected = props.pillSelected?.length !== 0;
3232

33-
React.useImperativeHandle(ref, () => {
34-
return listEl.current as HTMLDivElement;
35-
}, []);
33+
React.useImperativeHandle(
34+
ref,
35+
() => {
36+
return listEl.current as HTMLDivElement;
37+
},
38+
[]
39+
);
3640

3741
return (
3842
<PillSelectorWrapper

src/components/thirdPartyAnimation/thirdPartyAnimation.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ const ThirdPartyAnimationComponent = <V extends string | unknown>(
2222
const { thirdPartyAnimationData } = variantTheme;
2323
const element = React.useRef<HTMLDivElement>(null);
2424

25-
React.useImperativeHandle(ref, () => {
26-
return element.current as HTMLDivElement;
27-
}, []);
25+
React.useImperativeHandle(
26+
ref,
27+
() => {
28+
return element.current as HTMLDivElement;
29+
},
30+
[]
31+
);
2832

2933
React.useEffect(() => {
3034
if (element.current) {

src/components/tooltip/tooltipUnControlled.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ const TooltipUnControlledComponent = React.forwardRef(
2929
styleTooltipAsModal: styles.tooltipAsModal,
3030
});
3131

32-
React.useImperativeHandle(ref, () => {
33-
return labelRef.current as HTMLDivElement;
34-
}, []);
32+
React.useImperativeHandle(
33+
ref,
34+
() => {
35+
return labelRef.current as HTMLDivElement;
36+
},
37+
[]
38+
);
3539

3640
const { showTooltip, hideTooltip, allowFocusOpenTooltip, open } = useTooltip<V>({
3741
labelRef,

0 commit comments

Comments
 (0)