Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Bouquet committed Jan 19, 2023
1 parent 6aeb835 commit 0ec63f5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
46 changes: 23 additions & 23 deletions packages/visx-demo/src/sandboxes/visx-tooltip/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,29 @@ const tooltipStyles = {
padding: 12,
};

type OverlayLayerProps = {
container: HTMLDivElement | null;
text: string;
className?: string;
placeAfterTooltipInDom?: boolean;
};

function OverlayLayer({ className, container, placeAfterTooltipInDom, text }: OverlayLayerProps) {
if (container) {
// Since we re-render the tooltip every time the pointer moves and its DOM node
// is placed at the end of the container, if placeAfterTooltipInDom is true we
// also want to re-render the overlay layer
const key = placeAfterTooltipInDom ? Math.random() : 'overlay-under';
return ReactDOM.createPortal(
<div className={className} key={key}>
{text}
</div>,
container,
);
}
return null;
}

export default function Example({ width, height, showControls = true }: TooltipProps) {
const [tooltipShouldDetectBounds, setTooltipShouldDetectBounds] = useState(true);
const [tooltipPortalShouldUseCustomContainer, setTooltipPortalShouldUseCustomContainer] =
Expand Down Expand Up @@ -260,26 +283,3 @@ export default function Example({ width, height, showControls = true }: TooltipP
</>
);
}

type OverlayLayerProps = {
container: HTMLDivElement | null;
text: string;
className?: string;
placeAfterTooltipInDom?: boolean;
};

function OverlayLayer({ className, container, placeAfterTooltipInDom, text }: OverlayLayerProps) {
if (container) {
// Since we re-render the tooltip every time the pointer moves and its DOM node
// is placed at the end of the container, if placeAfterTooltipInDom is true we
// also want to re-render the overlay layer
const key = placeAfterTooltipInDom ? Math.random() : 'overlay-under';
return ReactDOM.createPortal(
<div className={className} key={key}>
{text}
</div>,
container,
);
}
return null;
}
6 changes: 5 additions & 1 deletion packages/visx-tooltip/src/hooks/useTooltipInPortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ export default function useTooltipInPortal({
}
}, [portalContainer]);

React.useEffect(updatePortalContainerRect, [containerBounds, portalContainer]);
React.useEffect(updatePortalContainerRect, [
containerBounds,
portalContainer,
updatePortalContainerRect,
]);
useResizeObserver(portalContainer ?? null, updatePortalContainerRect);

const TooltipInPortal = useMemo(
Expand Down

0 comments on commit 0ec63f5

Please sign in to comment.