Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 5f7bca5

Browse files
committed
fix: update and forceUpdate TS types
1 parent 8a034c6 commit 5f7bca5

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

typings/react-popper.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ export function usePopper(
5858
styles: { [key: string]: React.CSSProperties };
5959
attributes: { [key: string]: { [key: string]: string } };
6060
state: PopperJS.State;
61-
update: Pick<PopperJS.Instance, 'update'>;
62-
forceUpdate: Pick<PopperJS.Instance, 'forceUpdate'>;
61+
update: PopperJS.Instance['update'] | null;
62+
forceUpdate: PopperJS.Instance['forceUpdate'] | null;
6363
};

typings/tests/main-test.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,23 @@ const HookTest = () => {
5656
const [arrowElement, setArrowElement] = React.useState<HTMLElement | null>(
5757
null
5858
);
59-
const { styles, attributes } = usePopper(referenceElement, popperElement, {
60-
modifiers: [{ name: 'arrow', options: { element: arrowElement } }],
61-
});
59+
const { styles, attributes, update } = usePopper(
60+
referenceElement,
61+
popperElement,
62+
{
63+
modifiers: [{ name: 'arrow', options: { element: arrowElement } }],
64+
}
65+
);
6266

6367
return (
6468
<>
65-
<button type="button" ref={setReferenceElement}>
69+
<button
70+
type="button"
71+
ref={setReferenceElement}
72+
onClick={() => {
73+
update && update();
74+
}}
75+
>
6676
Reference element
6777
</button>
6878

0 commit comments

Comments
 (0)