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

Commit

Permalink
fix: update and forceUpdate TS types
Browse files Browse the repository at this point in the history
  • Loading branch information
FezVrasta committed Apr 11, 2020
1 parent 8a034c6 commit 5f7bca5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions typings/react-popper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ export function usePopper(
styles: { [key: string]: React.CSSProperties };
attributes: { [key: string]: { [key: string]: string } };
state: PopperJS.State;
update: Pick<PopperJS.Instance, 'update'>;
forceUpdate: Pick<PopperJS.Instance, 'forceUpdate'>;
update: PopperJS.Instance['update'] | null;
forceUpdate: PopperJS.Instance['forceUpdate'] | null;
};
18 changes: 14 additions & 4 deletions typings/tests/main-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,23 @@ const HookTest = () => {
const [arrowElement, setArrowElement] = React.useState<HTMLElement | null>(
null
);
const { styles, attributes } = usePopper(referenceElement, popperElement, {
modifiers: [{ name: 'arrow', options: { element: arrowElement } }],
});
const { styles, attributes, update } = usePopper(
referenceElement,
popperElement,
{
modifiers: [{ name: 'arrow', options: { element: arrowElement } }],
}
);

return (
<>
<button type="button" ref={setReferenceElement}>
<button
type="button"
ref={setReferenceElement}
onClick={() => {
update && update();
}}
>
Reference element
</button>

Expand Down

0 comments on commit 5f7bca5

Please sign in to comment.