@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
25 lines (23 loc) • 592 B
JavaScript
import { useRef, useState, useCallback } from "react";
const useErrorTooltip = ({
onFocus
}) => {
const [tooltipShown, setTooltipShown] = useState(false);
const [tooltipShownHover, setTooltipShownHover] = useState(false);
const labelRef = useRef(null);
const iconRef = useRef(null);
const handleFocus = useCallback(ev => {
if (onFocus) onFocus(ev);
setTooltipShown(true);
}, [onFocus]);
return {
tooltipShown,
tooltipShownHover,
setTooltipShown,
setTooltipShownHover,
labelRef,
iconRef,
handleFocus
};
};
export default useErrorTooltip;