Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleMouseEnter(el, type, e) {
const { onMouseEnter, children } = this.props;
const tooltipItem = findChildByType(children, Tooltip);
if (tooltipItem) {
this.setState(
{
activeElement: el,
activeElementType: type,
isTooltipActive: true
},
() => {
if (onMouseEnter) {
onMouseEnter(el, type, e);
}
}
);
} else if (onMouseEnter) {
onMouseEnter(el, type, e);
handleMouseLeave(el, type, e) {
const { onMouseLeave, children } = this.props;
const tooltipItem = findChildByType(children, Tooltip);
if (tooltipItem) {
this.setState(
{
isTooltipActive: false
},
() => {
if (onMouseLeave) {
onMouseLeave(el, type, e);
}
}
);
} else if (onMouseLeave) {
onMouseLeave(el, type, e);
}
}
renderTooltip() {
const { children, width, height, nameKey } = this.props;
const tooltipItem = findChildByType(children, Tooltip);
if (!tooltipItem) {
return null;
}
const { isTooltipActive, activeElement, activeElementType } = this.state;
const viewBox = { x: 0, y: 0, width, height };
const coordinate = activeElement
? getCoordinateOfTooltip(activeElement, activeElementType)
: defaultCoordinateOfTooltip;
const payload = activeElement
? getPayloadOfTooltip(activeElement, activeElementType, nameKey)
: [];
return React.cloneElement(tooltipItem, {
viewBox,